Question: semaphores_01.c Please help, ive been working on it for hours. I cant get the semaphores to work right. The order should be a,b,c,d,1,2,3. The program

semaphores_01.c

Please help, ive been working on it for hours. I cant get the semaphores to work right. The order should be a,b,c,d,1,2,3.
The program semaphores_01.c is the base over which you will work. There are a couple of problems with this program. First of all, sometimes the threads do not have a chance to complete, because the main program terminates without waiting for them. Second, the threads are not synchronized and therefore the text output is garbled Your task is to add semaphores to this program to synchronize the threads. You may declare the semaphores as global objects. The program semaph-ex.c gives you an example of synchronization with semaphores You should not sort the array nor use delays (like sleep)) to achieve the proper output. The synchronized output must be achieved through semaphores The program semaphores_01.c is the base over which you will work. There are a couple of problems with this program. First of all, sometimes the threads do not have a chance to complete, because the main program terminates without waiting for them. Second, the threads are not synchronized and therefore the text output is garbled Your task is to add semaphores to this program to synchronize the threads. You may declare the semaphores as global objects. The program semaph-ex.c gives you an example of synchronization with semaphores You should not sort the array nor use delays (like sleep)) to achieve the proper output. The synchronized output must be achieved through semaphores
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
