Question: Concurrency Control - Semaphore Add an additional thread to the example provided here and observe the outcome. To compile and link the program, use the

Concurrency Control - Semaphore
Add an additional thread to the example provided here and observe the outcome.
To compile and link the program, use the following command:
gcc -o sem-ex sem-ex.c -Wall -Werror -lpthread
Submission Instructions:
Upload a screenshot of your results.
~ $ gcc sema1.c -Wall -Werror -Ipthread -o sema1
~$ ls
2020-09-29-225106.term a1 p2 sema1
2020-09-30-103546.term a1.c p2.c sema1.c
~ ./sema1
Thread 1: Waiting to enter critical region...
Jhread 1: Now in critical region...
Thread 1: Counter Value: 0
Thread 1: Incrementing Counter...
Thread 1: New Counter Value: 1
Thread 1: Exiting critical region...
Thread 0: Waiting to enter critical region...
Thread 0: Now in critical region...
Thread 0: Counter Value: 1
Thread 0: Incrementing Counter...'
Thread 0: New Counter Value: 2
Thread 0: Exiting critical region...
Concurrency Control - Semaphore Add an additional

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 Programming Questions!