Sie sind auf Seite 1von 5

Homework 3

105.11.11
Problem 1. We can describe much of processor management in terms of process state transition diagram, such
as:
Waiting
4

3
2

Ready

Running

(1) What event causes each of the marked transitions?


(2) When we view all the processes in the system, we can see that a state transition by one process could cause
another process to make a state transition also. Under what circumstances could transition 3 by one process
immediately cause transition 2 by another process? That is the cause-and-effect transition 3 2.
(3) Under what circumstances, if any, could the following cause-and-effect transition occur?
(i) 1 2 (ii) 3
1 (iii) 4 2.

1) 4
2) 3 2Ready JobRunning Process
3)
(i)()
(ii) Preemptiom
(iii) Ready
Problem 2. Suppose that the following processes arrive for execution at the times indicated. Each process will
run the listed amount of time. In answering the questions, use nonpreemptive scheduling and base all
decisions on the information you have at the time the decision must be made.

a. What is the average turnaround time for these processes with the FCFS scheduling algorithm?
b. What is the average turnaround time for these processes with the SJF scheduling algorithm?
c. 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 processes P1 and P2 are waiting during this idle time, so their waiting time may increase.
This algorithm could be known as future-knowledge scheduling.

((P1's waiting time + P1's brust time) +


(P2's waiting time + P2's brust time) +
(P1's waiting time + P1's brust time)) / 3
a. ((0 + 8) + (7.6 + 4) + (11+ 1) ) / 3 = 10.5333
b. ((0 + 8) + (8.6 + 4) + (7+ 1) ) / 3 = 9.5333
c. ((6 + 8) + (1.6 + 4) + (0+ 1) ) / 3 = 6.866

Problem 3. Given the following information:


Job
Arrival Time
CPU Cycle
A
0
10
B
2
12
C
3
3
D
6
1
E
9
15
Draw a Gantt chart for each of the following . (It may be helpful to first compute a start and finish time for
each job.)
(a) FCFS (b) SJF (c) SRTF
(d) Round robin (using a time quantum of 5, ignore context switching and natural wait)
Problem 4. Using the same information given for Problem 3, compute the waiting time and turnaround time for
every job for each of the following scheduling algorithms (ignoring context switching overhead).
(a) FCFS (b) SJF (c) SRTF
(d) Round robin (using a time quantum of 5, ignore context switching and natural wait)
(a) FCFS (First-come, first served)
A
B
C
D
E
Turnaround Time[10(10+0) + 20(12+8) + 22(3+19) + 20(1+19) + 32(15+17)] / 5 = 20.8
Initial Wait
(0 + 8 + 19 + 19 + 17) / 5 = 12.6
Internal Wait
(0 + 0 + 0 + 0 + 0) / 5 = 0
(b)SJF(Shortest-job-fist)
A
D
C
B
Turnaround Time[10(10+0) + 24(12+12) + 11(3+8) + 5(1+4) + 32(15+17)] / 5 = 16.4
Initial Wait
(0 + 12 + 8 + 4 + 17) / 5 = 12.6
Internal Wait
(0 + 0 + 0 + 0 + 0) / 5 = 0
(c)SRTF(Shortest-remaining-time-first)
A1
C
D
A2
B

Turnaround Time[14(10+4) + 24(12+12) + 3(3+0) + 1(1+0) + 32(15+17)] / 5 = 14.8


Initial Wait
(0 + 12 + 0 + 0 + 17) / 5 = 5.8
Internal Wait
(4 + 0 + 0 + 0 + 0) / 5 = 0.8
Total Wait Time (4 + 12 + 0 + 0 + 17) / 5 = 6.6
(d)RR(Round-robin)
A1
B1
C
A2
D
E1
B2
E2
B3
Turnaround Time[18(10+8) + 34(12+22) + 10(3+7) + 13(1+12) + 32(15+17)] / 5 = 21.4
Initial Wait
(0 + 3 + 7 + 12 + 10) / 5 = 6.4
Internal Wait
(8 + 19 + 0 + 0 + 7) / 5 = 6.8
Total Wait Time (8 + 22 + 7 + 12 + 17) / 5 = 13.2

E3

Problem 5. Select the correct answer in each of the following questions.


1. ( D ) The user-level threads (a) are unknown by the kernel (b) are inexpensive to create
(c) are more powerful than the kernel threads (d) both a and b (e) both b and c

2. ( B ) The short-term scheduler is


(a) the one that determines which jobs will be admitted to the system for processing
(b) the one selects from the jobs in memory, which are ready to execute, and allocates the CPU to one of them
(c) the one that selects from the spooler and loads the jobs into memory for execution
(d) none of the above

3. ( F ) The long-term scheduler is responsible for


(a) determining which jobs will be admitted to the system for processing

(b) selecting from the jobs in memory and allocates the CPU to one of them
(c) selecting a good mix of I/O bound and CPU bound jobs
(d) all of the above (e) a and b only (f) a and c only

4. ( C ) When is the long-term scheduler invoked?


(a) When a job is completed. (b) When the degree of multiprogramming hasnt been reached.
(c) both a and b (d) none of the above
long-term scheduler() degree of multiprogramming()

5. ( A ) For the interprocess communication, if the unbounded-buffer is implemented then


(a) the sender never blocks. (b) the receiver never blocks. (c) the sender should wait until the buffer is empty
(d) the receiver should wait until the buffer is empty

6. ( A ) The issuing of a "READ" command by a user program will change the status of the process from
(a) run to wait (b) ready to run (c) ready to wait (d) wait to ready (e) wait to run
7. ( D ) At completion of an I/O command the status of the process that had issued the I/O command will change
from (a) run to wait (b) ready to run (c) ready to wait (d) wait to ready (e)
wait to run
8. ( B ) The scheduling of a process that has not yet RUN will change from
(a) run to wait (b) ready to run (c) ready to wait (d) wait to ready (e) wait to run
9. ( D ) The process control block is used to

(a) keep track of the status of a process


(b) keep track of the address of the next instruction to be executed for this process
(c) keep track of CPU scheduling information related to this process
(d) all of the above

10. ( A ) Knowing that a preemptive scheduling policy for the CPU indicates that
(a) the CPU can be taken away from one process and given to another process
(b) the CPU cannot be taken away from one process and given to another process
(c) the process in the running state can be moved to waiting state
(d) both a and c (e) both b and c (f) none of the above

Das könnte Ihnen auch gefallen