HW-3

advertisement
KSU/CCIS
CSC227
HOMEWORK # 3 – Threads and CPU Scheduling
SUMMER – 2010
Deadline 7-8/08/2010 (hard-copy in Tutorial Time)
Threads
Question # 1:
Describe similarities and differences between thread and process.
Question # 2:
Describe the pros and cons of using kernel- versus user-level threads?
Question # 3:
Describe the pros and cons of writing a program with multiple threads (as opposed to a single
thread).
Question # 4:
Consider the code
int x=0;
int y =0;
Give all values you could see for r1 and r2 after running this code:
a) Regular machine with one CPU
b) Machine with one CPU (the CPU is enabled to run just one instruction for each
thread before the timer expires)
c) Machine with parallel processors
CPU Scheduling
Question # 5:
Explain the advantages and disadvantages of Shortest-Job-First (SJF) scheduling. Explain
why we say that the Multi-Level-Feedback-Queue (MLFQ) is an approximation to SJF. Why
does MLFQ not have the disadvantages of SJF?
Question # 6:
Suppose that the following processes arrive for execution at the times indicated. Each process
will run the listed amount of time. In answering the question, the non-preemptive scheduling
and base all decisions on the information you have at the time the decision must be made.
P1
P2
P3
Arrival Time
CPU Burst
0.0
0.4
1.0
8
4
1
a) Fill the entries of the following table for each indicated scheduling policy and each
process. Ignore context switching overhead.
Scheduling Policy
Turnaround Time
P1
P2
P3
Average
Turnaround Time
FCFS
SJF (Non-Preemptive)
b) The SJF algorithm is supposed to improve performance, but notice that we chose to run
process P1 at time 0 because we did not know that two shorter processes would arrive
soon. Compute what the average turnaround time will be if the CPU is left idle for the
first 1 unit and then SJF scheduling is used. Remember that process P1 and P2 are
waiting during this idle time, so their waiting time may increase.
Scheduling Policy
SJF (Non-Preemptive)
Turnaround Time
P1
P2
P3
Average
Turnaround Time
Download