Tutorial3

# Tutorial3 - problem for two threads Argue for its...

This preview shows page 1. Sign up to view the full content.

Tutorial III October 25, 2010 Question 1 (2007/08 Examination) Assume all the processes in a process set arrive at time 0 in the following order: P1, P2, P3, P4, P5, P6 The table below shows the CPU burst time and priority (with a smaller number implies a higher priority) for each process. Process CPU Burst Time Priority P1 8 1 P2 2 3 P3 3 6 P4 1 5 P5 6 4 P6 4 2 i. Draw a timeline diagram for each of the following scheduling algorithms: FIFO, SPF, non-preemptive priority, and RR with quantum = 2. Assuming context switching overhead is negligible. ii. Compute the average waiting time and average normalized turnaround time for each scheduling algorithm and determine which one gives the worst results. Question 2 (2007/08 Assignment) Consider the following code fragment that implements a software solution to the mutual exclusion
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: problem for two threads. Argue for its correctness or show a case in which it fails. int favoredThread = 1; bool t1WantsToEnter = false; bool t2WantsToEnter = false; T1 T2 while (!done) { while (!done) { //enterMutualExclusion //enterMutualExclusion t1WantsToEnter = true; t2WantsToEnter = true; while (favoredThread != 1) { while (favoredThread != 2) { while (t2WantsToEnter); while (t1WantsToEnter); favoredThread = 1; favoredThread = 2; } } //inside critical section //inside critical section //exitMutualExclusion //exitMutualExclusion t1WantsToEnter = false; t2WantsToEnter = false; //outside critical section //outside critical section } }...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern