Question: help me urgent Problem 1 - Threads and Semaphores Solving the below three parts consists in replacing each question mark by the correct code. In

help me urgent

help me urgent Problem 1 - Threads and Semaphores Solving the below

Problem 1 - Threads and Semaphores Solving the below three parts consists in replacing each question mark by the correct code. In the loftmost box below, you must choose the initial value for the shared semaphore S. In the other two boxes, you must add the necessary calls. Each question mark can be either replaced by one or more semaphore calls, or left blank if no synchronization is required. Part 1 Consider the program below with two threads running concurrently. Add the necessary synchronizations so that this program satisfies the constraint C1-C2, i.e. thread B must not start executing C2 before thread A has finished executing Ci. Thread A Throad B Initial conditions Semaphore S =) 2 C2; 2 CI; 3 ? Part 2 Consider the program below with two threads running concurrently. Add all the necessary synchronizations so that this program satisfies the graph C1-C2-C3. You may want to use several semaphores. In all cases, don't forget to specify the initial value of each semaphore. Thread A Thread B Initial conditions 2 C1: 3 ? 4 C3; SP ? 2 C2: 3 ? Part 3 Consider the program below with two threads running concurrently. Add the necessary synchronizations so that execution alternates forever, i.e. C1, C2, C1, C2, C1, C2... Don't forget to indicate the initial conditions. Thread Thread B Initial conditions 2 while(true) 3 2 while(true){ 3 ? 4 5 6) C1: C2: ? 5 6)

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!