0% found this document useful (0 votes)
16 views20 pages

OS Solved Finals

The document is an exam paper for the Operating Systems course in the Electrical and Computer Engineering Program, dated June 13, 2018. It consists of five questions covering topics such as computer system components, operating system definitions, process operations, CPU scheduling, and calculations related to process execution times. The exam assesses various skills including knowledge, understanding, and professional skills related to operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views20 pages

OS Solved Finals

The document is an exam paper for the Operating Systems course in the Electrical and Computer Engineering Program, dated June 13, 2018. It consists of five questions covering topics such as computer system components, operating system definitions, process operations, CPU scheduling, and calculations related to process execution times. The exam assesses various skills including knowledge, understanding, and professional skills related to operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

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

Answer the Following Questions

The First Question (12 marks)


(a) Draw the component of a computer system?
(b) Define the Operating System?
(c) What are the operations on the process?
(d) State the difference between Process and Job?
The Second Question (08 marks)
(a) Draw the state diagram of the process?
(b) What is the cooperating process?
(c) Define the Process Control Block (PCB)?
(d) State the advantages of Multiprocessor Systems?
The Third Question (09 marks)
(a) What is the burst time of Process?
(b) What is Message-Passing System in InterProcess Communication(IPC)?
(c) What are the CPU scheduling criteria?
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.
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.
With my best wishes

This exam measures the following ILOs


Knowledge &Understanding Skills Intellectual Skills Professional Skills
Skills
A27 B18 C19
Question Number Q1 Q2 Q3 Q2 Q4,Q5 Q1 Q4,Q5

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

Answer Questions sheet

The First Question (12 marks)

(a) Draw the component of a computer system?


Ans: the component of the computer system is (1) Hardware. (2) Operating System. (3)
application programs. (4) Users. The hardware contains: CPU (Central Processing
Unit) or Microprocessor, Memory, and Input/Output Devices.

(b) Define the Operating System?


Ans: the operating system (OS) is the one program running at all times on the computer,
usually called kernel, with alleles being application programs. The OS controls and
coordinates the use of the hardware among the various applications for the various
users.
(c) What are the operations on process?
Ans: Process creation and Process termination operations.

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.

The Second Question (08 marks)

(a) Draw the state diagram of the process?

(b) What is the cooperating process?


Ans: A process is cooperating if it can effect or be affected by the other processes
executing in the system.

(c) Define the Process Control Block (PCB)?


Ans: Process Control Block (PCB) contains pieces of information associated with
specific process.

2
(d) State the advantages of Multiprocessor Systems?
Ans:
1- Increase the throughput
2- Economy of scale
3- Increase reliability (fault tolerant)

The Third Question (09 marks)

(a) What is the burst times of process?


Ans: CPU burst time is the time period of execution on CPU or Microprocessor. I/O burst
time is the waiting time of a process for an I/O operation.

(b) What is Message-Passing System in InterProcess Communication(IPC)?


Ans:
An IPC is used to exchange the data among the processes and IPC facility provides at least
two operations: send (MSG) and Receive (MSG).
There are two types of IPC:
1- Direct communications
I. Symmetric
II. Asymmetric
2- Indirect communication

(c) What are the CPU scheduling criteria?


Ans: CPU criteria are (1) CPU Utilization, (2) Throughput, (3) turnaround time, (4)
waiting time, (5) response time.

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

(a) CPU utilization


CPU Utilization = processing time/ Total time
= (45+55+35+60) / 215 = 195/215 = 0.9069
= 90.69 %
(b) The execution time for each process.

Process execution time = end time – start time


Exec (P1) = 176 – 0 = 176 ms
Exec (P2) = 193 – 0 = 193 ms
Exec (P3) = 147 – 0 = 147 ms
Exec (P4) = 215 – 0 = 215 ms

(c) The Waiting time for each process.

Waiting time = Execution time – Processing time


Waiting (P1) = 176 – 45 = 131 ms
Waiting (P2) = 193 – 55 = 138 ms
Waiting (P3) = 147 – 35 = 112 ms
Waiting (P4) = 215 – 60 = 155 ms

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

Turnaround time (p1) =5 -0 = 5 ms


Turnaround time (p2) = 8 – 1 = 7 ms
Turnaround time (p3) = 14 -2 = 12 ms
Turnaround time (p4) = 17 – 3 = 14 ms
(b) What is the average turnaround time and waiting time for these processes with the SJF
scheduling algorithm? In cases of both preemptive and non-preemptive.
Shortest-job First; Preemptive
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 11 -5- 0 =6
P2 1 3 waiting time (P2) = 4 – 3-1 = 0 Average waiting time = (6 +0+9+1)/4 = 4
P3 2 8 waiting time (P3) = 17 -6-2 =9
P4 3 4 waiting time (P4) = 7 –3-3 =1

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

Turnaround time (p1) =11 -0 = 11 ms


Turnaround time (p2) = 4 – 1 = 3 ms
Turnaround time (p3) = 17 -2 = 15 ms
Turnaround time (p4) = 7 – 3 = 4 ms
Shortest-job First; Non-Preemptive
Process arrival-time burst-time

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

Turnaround time (p1) =5 -0 = 5 ms


Turnaround time (p2) = 8 – 1 = 7 ms
Turnaround time (p3) = 17 -2 = 15 ms
Turnaround time (p4) = 11 – 3 = 8 ms

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

Answer the Following Questions

The First Question (12 marks)


(a) What is the component of a computer system?
(b) What is an Operating System?
(c) What is “Job Pool”?
(d) What are the operations on the process?
The Second Question (08 marks)
(a) Draw a state diagram of the process?
(b) Define the cooperating process?
(c) What is the difference between Process and Job?
(d) What is the Process Control Block (PCB)?
The Third Question (09 marks)
(a) What is meant of CPU and I/O burst times?
(b) What is meant of Time-Sharing and multiprogramming?
(c) What are the CPU scheduling criteria?
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.
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.
With my best wishes

This exam measures the following ILOs


Knowledge &Understanding Skills Intellectual Skills Professional Skills
Skills
A27 B18 C19
Question Number Q1 Q2 Q3 Q2 Q4,Q5 Q1 Q4,Q5

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

Answer Questions sheet

The First Question (12 marks)

(a) What is the component of a computer system?


Ans: the component of the computer system is (1) Hardware. (2) Operating System. (3)
application programs. (4) Users. The hardware contains: CPU (Central Processing
Unit) or Microprocessor, Memory, and Input/Output Devices.

(b) What is an Operating System?


Ans: the operating system (OS) is the one program running at all times on the computer,
usually called kernel, with alleles being application programs. The OS controls and
coordinates the use of the hardware among the various applications for the various
users.
(c) What is “Job Pool”?
Ans: the pool consists of all processes residing on disk awaiting allocation of main
memory.

1
(d) State the operations on process?
Ans: Process creation and Process termination operations.

The Second Question (08 marks)

(a) Draw a diagram of process states?

(b) What is the cooperating process?


Ans: A process is cooperating if it can effect or be affected by the other processes
executing in the system.

(c) What is the difference between Job and Process?


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.

(d) What is the Process Control Block (PCB)?


Ans: Process Control Block (PCB) contains pieces of information associated with
specific process.

2
The Third Question (09 marks)

(a) What is meant of CPU and I/O burst times?


Ans: CPU burst time is the time period of execution on CPU or Microprocessor. I/O burst
time is the waiting time of a process for an I/O operation.

(b) What is meant of Time-Sharing and multiprogramming?


Ans: Time sharing: it allows many users to share the computer simultaneously. As the
system switches rapidly from one user to the next, each user is given the impression
that the entire computer system is dedicated to her use.
Multiprogramming: the most important aspect of the job scheduling is the ability of
multiprogramming. It means many different jobs need to be executed
simultaneously. So the multiprogramming increases the CPU utilization.

(c) What are the CPU scheduling criteria?


Ans: CPU criteria are (1) CPU Utilization, (2) Throughput, (3) turnaround time, (4)
waiting time, (5) response time.

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

(a) CPU utilization


CPU Utilization = processing time/ Total time
= (40+50+30+60) / 198 = 180/198 = 0.9091
= 90.91 %

(b) The execution time for each process.

Process execution time = end time – start time


Exec (P1) = 108 – 0 = 108 ms
Exec (P2) = 176 – 0 = 176 ms
Exec (P3) = 142 – 0 = 142 ms
Exec (P4) = 198 – 0 = 198 ms

(c) The execution time for each process.

Waiting time = Execution time – Processing time


Waiting (P1) = 108 – 40 = 68 ms
Waiting (P2) = 176 – 50 = 126 ms
Waiting (P3) = 142 – 30 = 112 ms
Waiting (P4) = 198 – 60 = 138 ms

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

Turnaround time (p1) =7 -0 = 7 ms


Turnaround time (p2) = 10 – 1 = 9 ms
Turnaround time (p3) = 18 -2 = 16 ms
Turnaround time (p4) = 22 – 3 = 19 ms
(b) What is the average turnaround time and waiting time for these processes with the SJF
scheduling algorithm? In cases of both preemptive and non-preemptive.
Shortest-job First; Preemptive
Process arrival-time burst-time
P1 0 7 waiting time (P1) = 14 -7- 0 =7
P2 1 3 waiting time (P2) = 4 – 3-1 = 0 Average waiting time = (7 +0+12+1)/4 = 5
P3 2 8 waiting time (P3) = 22 -8-2 =12
P4 3 4 waiting time (P4) = 8 –4-3 =1

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

Turnaround time (p1) =14 -0 = 14 ms


Turnaround time (p2) = 4 – 1 = 3 ms
Turnaround time (p3) = 22 -2 = 20 ms
Turnaround time (p4) = 8 – 3 = 5 ms

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

Turnaround time (p1) =7 -0 = 7 ms


Turnaround time (p2) = 10 – 1 = 9 ms
Turnaround time (p3) = 22 -2 = 20 ms
Turnaround time (p4) = 14 – 3 = 11 ms

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

Answer the Following Questions

The First Question (12 marks)

(a) What is the component of a computer system?


(b) What is an Operating System?
(c) What is “Job Pool”?
(d) What is the Process Control Block (PCB)?
The Second Question (12 marks)

(a) Draw a diagram of process states?


(b) What is the cooperating process?
(c) What is the difference between Job and Process?
(d) Define the following: Job scheduling and CPU scheduling?
The Third Question (15 marks)
(a) What is meant of CPU and I/O burst times?
(b) What are the operations on process?
(c) What is meant of Time-Sharing and multiprogramming?
(d) What are the CPU scheduling criteria?

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?
(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

With my best wishes


This exam measures the following ILOs
Knowledge &Understanding Skills Intellectual Skills Professional Skills
Skills
A27 B18 C19
Question Number Q1 Q2 Q3 Q2 Q4 Q1 Q4

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

Answer Questions sheet

The First Question (12 marks)

(a) What is the component of a computer system?


Ans: the component of the computer system is (1) Hardware. (2) Operating System. (3)
application programs. (4) Users. The hardware contains: CPU (Central Processing
Unit) or Microprocessor, Memory, and Input/Output Devices.

(b) What is an Operating System?


Ans: the operating system (OS) is the one program running at all times on the computer,
usually called kernel, with alleles being application programs. The OS controls and
coordinates the use of the hardware among the various applications for the various
users.

(c) What is “Job Pool”?


Ans: the pool consists of all processes residing on disk awaiting allocation of main
memory.

1
(d) What is the Process Control Block (PCB)?
Ans: Process Control Block (PCB) contains pieces of information associated with
specific process.

The Second Question (12 marks)

(a) Draw a diagram of process states?

(b) What is the cooperating process?


Ans: A process is cooperating if it can effect or be affected by the other processes
executing in the system.

(c) What is the difference between Job and Process?


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) 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.

The Third Question (15 marks)

(a) What is meant of CPU and I/O burst times?


Ans: CPU burst time is the time period of execution on CPU or Microprocessor. I/O burst
time is the waiting time of a process for an I/O operation.

(b) What are the operations on process?


Ans: Process creation and Process termination operations.

(c) What is meant of Time-Sharing and multiprogramming?


Ans: Time sharing: it allows many users to share the computer simultaneously. As the
system switches rapidly from one user to the next, each user is given the impression
that the entire computer system is dedicated to her use.
Multiprogramming: the most important aspect of the job scheduling is the ability of
multiprogramming. It means many different jobs need to be executed
simultaneously. So the multiprogramming increases the CPU utilization.

(d) What are the CPU scheduling criteria?


Ans: CPU criteria are (1) CPU Utilization, (2) Throughput, (3) turnaround time, (4)
waiting time, (5) response time.

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

If we suppose that the first-come process is the shortest:


Process arrival-time burst-time
P1 0 3 waiting time (P1) = 0
P2 1 5 waiting time (P2) = 3 Average waiting time = (0 +3+8+16)/4 = 6.75
P3 2 8 waiting time (P3) = 8
P4 3 9 waiting time (P4) = 16
P1 P2 P3 P4
0 3 8 16 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

Another an example in case of with interrupting the process that is long:


Process arrival-time burst-time
P1 0 8 waiting time (P1) = 17 -8- 0 =9
P2 1 4 waiting time (P2) = 5 – 4-1 = 0 Average waiting time = (9 +0+15+2)/4 = 6.5
P3 2 9 waiting time (P3) = 26 -9-2 =15
P4 3 5 waiting time (P4) = 10 –5-3 =2
P1 P2 P2 P2 P4 P1 P3
0 1 2 3 5 10 17 26
p1 p1 p1 p1
p2 p2 p2
p3 p3
p4

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

Shortest-job First; Preemptive


Process arrival-time burst-time
P1 0 7 waiting time (P1) = 14 -7- 0 =7
P2 1 3 waiting time (P2) = 4 – 3-1 = 0 Average waiting time = (7 +0+12+1)/4 = 5
P3 2 8 waiting time (P3) = 22 -8-2 =12
P4 3 4 waiting time (P4) = 8 –4-3 =1

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

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

You might also like