Question: COMP301 - OPERATING SYSTEMS Fall 2021 Assignment - 2 DUE: 29 January 2021, 11:59PM Task Requirements Modify the following code to demonstrate context switching between

 COMP301 - OPERATING SYSTEMS Fall 2021 Assignment - 2 DUE: 29

COMP301 - OPERATING SYSTEMS Fall 2021 Assignment - 2 DUE: 29 January 2021, 11:59PM Task Requirements Modify the following code to demonstrate context switching between parallel running threads. The program must fulfil the following requirements: There should be 4 threads created using Pthreads API. While all/any the threads are running, the main() function should be waiting for the threads to finish their execution. The 1st thread should continuously print the character "1" in a loop. the 2nd thread should continuously print the character "2" in a loop. the 3rd thread should continuously print the character "3" in a loop. The 4th thread should continuously check for keyboard input. As soon as the user presses the Q key, the program should terminate. Right before termination, the main() function displays the number of 1's, 2's, and 3's printed out by each thread. 1 1 w PNP PPN Sample Output 11111111 11112222222222211 22222333 2211111111222222222 222222222 22222221111 113333333333333333133333331 33333322222222222221 3333 332222 22222 33332222222222222233333333333333333311111 1111 2222222223 Number of ls = 141 Number of 2s = 121 Number of 3s = 98 w PNP w PNP w PNP w PNP F H NMM H & M 12222222222 1222222 1111333 3333333 33333333333222 WPPPP WPPAN JW PN M SUBMISSION DETAILS: 1. There is one C file required as an outcome. The file must compile without Errors. 2. Name the file as rollno.ce.g. 12-12345.c, upload this file to Moodle

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!