Scenario of identical threads. 4. Consider Deitel's MoreonSemaphore.ppt, slide #4 as below Deitel This is about the same

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Scenario of identical threads. 4. Consider Deitel's MoreonSemaphore.ppt, slide #4 as below Deitel This is about the same

Post by answerhappygod »

Scenario Of Identical Threads 4 Consider Deitel S Moreonsemaphore Ppt Slide 4 As Below Deitel This Is About The Same 1
Scenario Of Identical Threads 4 Consider Deitel S Moreonsemaphore Ppt Slide 4 As Below Deitel This Is About The Same 1 (185.91 KiB) Viewed 36 times
Scenario Of Identical Threads 4 Consider Deitel S Moreonsemaphore Ppt Slide 4 As Below Deitel This Is About The Same 2
Scenario Of Identical Threads 4 Consider Deitel S Moreonsemaphore Ppt Slide 4 As Below Deitel This Is About The Same 2 (55.99 KiB) Viewed 36 times
Scenario of identical threads. 4. Consider Deitel's MoreonSemaphore.ppt, slide #4 as below Deitel This is about the same kind of threads competing for resources (with Race Condition) Suppose there are two threads T1 and T2. We have for T1 code as below: (and the code of T2 is identical to that of T1) 10 void main () 11 { 12 while (!done) 13 14 15 16 17 V(occupied); // signal 18 19 { P (occupied); // wait // critical section code 20 21 crl; cr2; // non-critical section code nc11; // code for T1 nc12; // code for T1 } // end while // Thread T1 Suppose all instructions from line 14 till line 19 each takes 10 milliseconds (so one iteration of while loop takes 60 milliseconds). Now we are doing round robin (RR) scheduling between thread T1 and thread T2 with each thread executing n milliseconds alternatively and we start execution at T1. For simplicity, assume it takes 0 (zero) milliseconds from line 10 till line 14. (a). Assume n = 60 (sixty) (so T1 and T2 run alternately every 60 milliseconds). Which instruction and which thread are we in at time t = 105? Why? Are T1 and T2 both executed by t = 105? Why? How about at time t = 150? Give the detail explanation on the sequence of instructions for every time slot using a table like below. Remember to explain if one thread is waiting for a semaphore or is signaled by a semaphore. Notice if a thread T is waiting for a semaphore and gets signaled that semaphore S is ready for use (the semaphore value for S becomes 1 now), thread T does NOT start running right away until OS gives it CPU time through Round Robin scheduling.
Time Thread T1 0 Table 7 Thread executions of T1 and T2 Time Thread Reason Answer why 10 T1 Instruction L 14: P 150 T1 T2? or Instruction L 15: cr1 Reason Answer why Round Robin (b) Now assume we do round robin with quantum 20 (twenty) milliseconds. Fill out another table T8 for where we are at which thread, which instruction, and the reason, for time t = 0, until t = 80.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply