Question: Operating Systems Programming. *Goal: split up printing of a C-string across two threads *Thread 1 prints 1st half of string, thread 2 prints 2nd half

Operating Systems Programming.

*Goal: split up printing of a C-string across two threads

*Thread 1 prints 1st half of string, thread 2 prints 2nd half of string

*Arguments: a pointer to the starting point in the string, the number of characters to print, and the length of the string (for bounds checking)

*Do not pass indices, we are going to practice with pointers

*TODO #1: write code showing how to do this without threads

*TODO #2: sketch how to do this with threads

*Write pseudocode or code to split the printing across 2 threads

*Things to think about:

*What are the arguments? will need to create a struct to pass these in

*How are pthread_create and join called? look at book examples, http://pages.cs.wisc.edu/~remzi/OSTEP/threads-intro.pdf

http://pages.cs.wisc.edu/~remzi/OSTEP/threads-api.pdf

*How does the thread function decode the argument array, which is a pointer to a struct?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!