OS Solved Finals
OS Solved Finals
0
Faculty of Engineering Final exam (2nd Term)
Electrical and Computer Time: 3 hours
Engineering Program Date: 13/06/2018
Operating Systems Examiner: Prof. Ayman EL-SAYED
1
(d) State the difference between Process and Job?
Ans: the job is a program that is in the disk waiting to be allocated in main memory. The
process is a program as well but it is residing in memory waiting to be running on
the microprocessor.
2
(d) State the advantages of Multiprocessor Systems?
Ans:
1- Increase the throughput
2- Economy of scale
3- Increase reliability (fault tolerant)
3
The Fourth Question (09 marks)
There is a computer system having 4 processes with burst time of 45 ms, 55 ms,35 ms and 60 ms
respectively, without I/O operations. The CPU running for each process only 20 ms. PCB size is 10 kb,
the data transfer rate in the system is 10 mbps. Suppose: 1 mb = 1000 kb, 1 kb = 1000 bits. Calculate the
following:
(a) CPU Utilization.
(b) The execution time for each process.
(c) The waiting time of each process.
Ans:
Exchange time = 2* 10 kb/10 Mbps = 2* 1/1000 sec = 2*1 ms = 2 ms
P1 P2 P3 P4 P1 P2 P3 P4 P1 P2 P4
(20ms) (20ms) (20ms) (20ms) (20ms) (20ms) (15ms) (20ms) (5ms) (15ms) (20ms)
20 42 64 86 108 130 147 169 176 193 215
4
The Fifth Question (12 marks)
Suppose that the following processes arrive for execution at the times indicated. Each process will run for
the amount of time listed. In answering the questions, use non-preemptive 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 and waiting Process arrival-time burst-time
time for these processes with the FCFS scheduling P1 0 5
algorithm? P2 1 3
(b)What is the average turnaround time and waiting P3 2 6
time for these processes with the SJF scheduling P4 3 3
algorithm? In cases of both preemptive and non-
preemptive.
Ans:
(a) What is the average turnaround time and waiting time for these processes with the FCFS
scheduling algorithm?
First-Come, First-Serve:
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 0
P2 1 3 waiting time (P2) = 5 – 1 = 4 Average waiting time = (0 +4+6+11)/4 = 5.25
P3 2 8 waiting time (P3) = 8 -2 =6
P4 3 4 waiting time (P4) = 14 – 3= 11
P1 P2 P3 P4
0 5 8 14 17
P1 P2 P2 P2 P4 P1 P3
0 1 2 3 4 7 11 17
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4
5
P1 0 7 waiting time (P1) = 5 -5- 0 =0
P2 1 3 waiting time (P2) = 8 – 3-1 = 4 Average waiting time = (0 +4+9+5)/4 = 4.5
P3 2 8 waiting time (P3) = 17 -6-2 =9
P4 3 4 waiting time (P4) = 11 –3-3 =5
P1 P2 P4 P3
0 1 2 3 5 8 11 17
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4
6
Faculty of Engineering Final exam (2nd Term)
Electrical and Computer Time: 3 hours
Engineering Program Date: 30 /05/2017
Operating System Examiner: Prof. Ayman EL-SAYED
0
Faculty of Engineering Final exam (1st Term)
Electrical and Computer Time: 3 hours
Engineering Program Date: 05/01/2017
Operating System Examiner: Prof. Ayman EL-SAYED
1
(d) State the operations on process?
Ans: Process creation and Process termination operations.
2
The Third Question (09 marks)
3
The Fourth Question (09 marks)
There is a computer system having 4 processes with processing time of 40 ms, 50 ms,30 ms and 60 ms
respectively, without I/O operations. The CPU running for each process only 20 ms. PCB size is 10 kb,
the data transfer rate in the system is 10 mbps. Suppose: 1 mb = 1000 kb, kb = 1000 bits. Calculate the
following:
(a) CPU Utilization.
(b) The execution time for each process.
(c) The waiting time of each process.
Ans:
Exchange time = 2* 10 kb/10 Mbps = 2* 1/1000 sec = 2*1 ms = 2 ms
P1 P2 P3 P4 P1 P2 P3 P4 P2 P4
(20ms) (20ms) (20ms) (20ms) (20ms) (20ms) (10ms) (20ms) (10ms) (20ms)
20 42 64 86 108 130 142 164 176 198
4
The Fifth Question (12 marks)
Suppose that the following processes arrive for execution at the times indicated. Each process will run for
the amount of time listed. 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 and waiting Process arrival-time burst-time
time for these processes with the FCFS scheduling P1 0 7
algorithm? P2 1 3
(b)What is the average turnaround time and waiting P3 2 8
time for these processes with the SJF scheduling P4 3 4
algorithm? In cases of both preemptive and non-
preemptive.
Ans:
(a) What is the average turnaround time and waiting time for these processes with the FCFS
scheduling algorithm?
First-Come, First-Serve: Preemptive and Non-preemptive
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 0
P2 1 3 waiting time (P2) = 7 – 1 = 6 Average waiting time = (0 +6+8+15)/4 = 7.25
P3 2 8 waiting time (P3) = 10 -2 =8
P4 3 4 waiting time (P4) = 18 – 3= 15
P1 P2 P3 P4
0 7 10 18 22
P1 P2 P2 P2 P4 P1 P3
0 1 2 3 4 8 14 22
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4
5
Shortest-job First; Non-Preemptive
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 7 -7- 0 =0
P2 1 3 waiting time (P2) = 10 – 3-1 = 6 Average waiting time = (0 +6+12+7)/4 = 6.25
P3 2 8 waiting time (P3) = 22 -8-2 =12
P4 3 4 waiting time (P4) = 14 –4-3 =7
P1 P2 P4 P3
0 1 2 3 7 10 14 22
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4
6
Faculty of Engineering Final exam (1st Term)
Electrical and Computer Time: 3 hours
Engineering Program Date: 22/01/2015
Operating System Examiner:Prof. Ayman EL-SAYED
(a) Explain the first-come, first-serve CPU scheduling algorithm and the Shortest-job-first CPU
scheduling algorithm with given an example?
(b) By using both first-come, first-serve CPU scheduling algorithm and Shortest-job-first CPU
scheduling algorithm, explain how to schedule the following processes and obtain the average
waiting time of both the CPU scheduling in case of both preemptive and non-preemptive:
Process arrival-time burst-time
P1 0 7
P2 1 3
P3 2 8
P4 3 4
0
Faculty of Engineering Final exam (1st Term)
Electrical and Computer Time: 3 hours
Engineering Program Date: 22/01/2015
Operating System Examiner:Prof. Ayman EL-SAYED
1
(d) What is the Process Control Block (PCB)?
Ans: Process Control Block (PCB) contains pieces of information associated with
specific process.
2
(d) Define the following: Job scheduling and CPU scheduling?
Ans: Job scheduling is used to allocate some processes in main memory. If several jobs
are ready to be brought into memory and if there is not enough room for all of them,
then the system (OS) must choose among them. This is called Job Scheduling.
3
The Fourth Question (15 marks)
(a) Explain the first-come, first-serve CPU scheduling algorithm and the Shortest-job-first CPU
scheduling algorithm with given an example?
Ans: to explain this scheduling algorithm, we give an example:
Process arrival-time burst-time
P1 0 9 waiting time (P1) = 0
P2 1 8 waiting time (P2) = 9 Average waiting time = (0 +9+17+22)/4 = 12
P3 2 5 waiting time (P3) = 17
P4 3 3 waiting time (P4) = 22
P1 P2 P3 P4
0 9 17 22 25
We note that the first come, first serve is better in the case of the shortest process coming
first than in the else cases.
To explain Shortest-job First we give an example in case of without interrupting any long
process:
Process arrival-time burst-time
P1 0 8 waiting time (P1) = 0-0 =0
P2 1 4 waiting time (P2) = 8-1 = 7 Average waiting time = (0 +7+15+9)/4 = 7.75
P3 2 9 waiting time (P3) = 17 -2 =15
P4 3 5 waiting time (P4) = 12 -3 =9
P1 P2 P4 P3
0 8 12 17 26
The problem occurs when the longest process coming first and the other coming
processes are shorter than it, so the longest (first) process don’t be completed before
all the other processes (shortest) completed.
4
(b) By using both first-come, first-serve CPU scheduling algorithm and Shortest-job-first CPU
scheduling algorithm, explain how to schedule the following processes and obtain the average
waiting time of both the CPU scheduling in case of both preemptive and non-preemptive:
Process arrival-time burst-time
P1 0 7
P2 1 3
P3 2 8
P4 3 4
Ans:
First-Come, First-Serve: Preemptive and Non-preemptive
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 0
P2 1 3 waiting time (P2) = 7 – 1 = 6 Average waiting time = (0 +6+8+15)/4 = 7.25
P3 2 8 waiting time (P3) = 10 -2 =8
P4 3 4 waiting time (P4) = 18 – 3= 15
P1 P2 P3 P4
0 7 10 18 22
P1 P2 P2 P2 P4 P1 P3
0 1 2 3 4 8 14 22
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4
P1 P2 P4 P3
0 1 2 3 7 10 14 22
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4