Question: Exercise 4.2 Modify the example program (lab4.c) to use a mutex and a condition variable to print the character string '0123456789' using 2 threads A


Exercise 4.2 Modify the example program (lab4.c) to use a mutex and a condition variable to print the character string '0123456789' using 2 threads A and B, with Thread A printing characters '0', '1', '2', '3' and '4' and Thread B printing characters '5', '6', '7', '8' and '9'. You should use 2 separate thread functions for the threads, and modify the format control string ".c" in the printf) statement in the thread function of the example program to "A%c " for Thread A, and "B/hc " for Thread B If the program works correctly, the string "A0 A1 A2 A3 A4 B5 B6 B7 B8 B9" will appear repeatedly on the screen
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
