Given the following 3 threads and a shared global variable Xinitialized to 0: T1
ID: 3609350 • Letter: G
Question
Given the following 3 threads and a shared global variable Xinitialized to 0: T1(){ T2(){ T3( ){ while(x!=3){ while(x!=3){ while(x !=3){ x =1; if(x == 1) x =2 if(x == 2) x = 3 } } } } } } Assume the order that at which the threads enter the system isnot know, but any order is equally likely, what is theprobability of termination for each one of the following CPUscheduling policies. round robin shortest job first (no preemption, equal execution time) random (when a time quantum expires, scheduler selects athread in a random manner) Given the following 3 threads and a shared global variable Xinitialized to 0: T1(){ T2(){ T3( ){ while(x!=3){ while(x!=3){ while(x !=3){ x =1; if(x == 1) x =2 if(x == 2) x = 3 } } } } } } Assume the order that at which the threads enter the system isnot know, but any order is equally likely, what is theprobability of termination for each one of the following CPUscheduling policies. round robin shortest job first (no preemption, equal execution time) random (when a time quantum expires, scheduler selects athread in a random manner)Explanation / Answer
Dear, Given, threads excecution is, T1 () { T2 () { T3() { while(x!= 3) { while(x!= 3 ) { while(x! = 3 ) { x= 1; if(x==1) x=3; if(x==2) x=3; } } } } } } Here the threee threads share a globalvariable "x" whose initial value is 0. During execution initially the value of "x"is 0, so, it enters the loop, then its value changed to 1. Then by"if" condition the value of "x" ix assigned to 3. In the first runall the three threads are executed. Now, the value of "x" is 3. So,the process will be terminated at the thread 3. b) Round Robin : Inthe round robin scheduling the threads are executed in the orderT1,T2,T3,T1,T2,T3....... Inthis scheduling the termination occurs when the condition fails,Even the condition is failed at the thread T3 in the first run,again the threads T1,T2, and T3 are executed. In this theprobability of temination is high. Shortest job first: In thisscheduling first the shortest job is executed and then the complexone. Here the probability of termination is also low when comparedto round robin scheduling. Random Scheduling: This is thebest scheduling process than the round robin and the shortest jobscheduling algorithms. Here a specified quantum is assigned for thethread execution. If the the quantum is expired then the threadswill be terminated. " I hope this will help you " This is thebest scheduling process than the round robin and the shortest jobscheduling algorithms. Here a specified quantum is assigned for thethread execution. If the the quantum is expired then the threadswill be terminated. " I hope this will help you "Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.