University of Houston
COSC 3360
COSC 3360 - 15065 - Fundamentals of Operating Systems
Write a C++ program that creates multiple POSIX threads. Each child thread prints a message to STDOUT with the thread numb must guarantee that the messages are printed in ascending order (first even, then odd). The program executes the following tas
1. Receives as input a positive inte
...[Show More]
COSC 3360 - 15065 - Fundamentals of Operating Systems
Write a C++ program that creates multiple POSIX threads. Each child thread prints a message to STDOUT with the thread numb must guarantee that the messages are printed in ascending order (first even, then odd). The program executes the following tas
1. Receives as input a positive integer value representing the number of child threads.
2. Creates "nThreads" child threads (where "nThreads" is the number from the input).
3. Assigns a thread number to each child thread based on the order they are created. The value for the thread number mu
and be increased by one before assigning it to the next child thread. You must guarantee that the first child thread has
equal to zero, the second child thread has a thread number equal to one, and the nth child thread has a thread number
4. Each child thread prints a predefined message (available in the template file). The print statement executed by the child
inside of a critical section.
5. Your program must guarantee that the messages are printed in ascending order (first even, then odd).
For a number of threads = 5, the expected output is:
I am child thread 0
I am child thread 2
I am child thread 4
I am child thread 1
I am child thread 3
NOTES
1. You must create n child threads (where n is the positive integer value from the input).
2. You can only use POSIX semaphores, pthreads mutex semaphores, or pthreads condition variables to achieve sync
penalty of 100% will be applied to solutions using mechanisms other than the synchronization mechanisms listed
3. A penalty of 100% will be applied to solutions that do not assign the "threadNumber" based on the specifications
4. Programs not compiling will receive a penalty of 100%.
5. To simplify your solution, the template file defines several global variables that you are allowed to use in your pro
programming question. However, remember that you should avoid using global variables when writing programs
[Show Less]