Processes in Operating System

 

 

Important Points

  •  Burst time is total time required for execution, which is given in problem
  • Arrival time is moment at which job is submitted into a queue , which is given in problem
  • start time is time at which procees starts its execution
  • Finish time of every process is calulated by addition of start time and burst time of that process
  • wait time of every process is calculated by subtraction of start  time and arrival time of that  process
  • Turn around time of every process is calculated by subtraction of finish time and arrival time
  • Avearge wait time is calculated by average of wait time of all processes.'
  • Average turn around time is calculated by average of turn around time of all processes. 
  • Belady's Anomaly - If there are three free frames and we are finding the total page faults , this page fault should be reduced if we increase number of free frames then number of page faults should be decreased. When this does not happen , then exception is called belady's anomaly.

 

Consider the following set of processes with the length of CPU  burst time and arrival time given in milli seconds
 

 

Process

Burst Time

Arrival Time

P1

5

1.5

P2

1

0

P3

2

2

P4

4

3

 

Illustrate the execution of these process using FCFS CPU Scheduling algorithems. Also calculate wait timeand turn around timeof each process and calculate average waiting time and average turn around time for above situation. Also draw a gantt chart.

 

 Solution :

Process

(1)

Burst Time

(2)

Arrival Time

(3)

Start Time

(4)

Wait Time

(5)

(4)-(3)

 

Finish Time

(6)

(4)+(2)

Turn Around Time

(7)

(6)-(3)

P1

5

1.5

1.5

0

6.5

5

P2

1

0

0

0

1

1

P3

2

2

6.5

5.5

8.5

6.5

P4

4

3

8.5

5.5

12.5

9.5

 

Now calculate average wait time 

Average Wait time =10/4=2.5

average turn around time=22/4=5.5

Gantt Chart 

 

 

P2

         

P1

P3

P4

0                      1                1.5                     6.5                       8.5              12.5   
 

In the shaded area CPU is idle and not doing any thing because no process is in ready queue 


Consider the following set of processes with the length of CPU  burst time and arrival time given in milli seconds

 

 

Process

Burst Time

Arrival Time

P1

2

1

P2

3

2

P3

5

0

 

Illustrate the execution of these process using pre-emptive SJF CPU Scheduling algorithems. Also calculate wait time and turn around timeof each process and calculate average waiting time and average turn around time for above situation

 

Solution

Process

(1)

Burst Time

(2)

Arrival Time

(3)

Start Time

(4)

Wait Time

(5)

(4)-(3)

 

Finish Time

(6)

(4)+(2)

Turn Around Time

(7)

(6)-(3)

P1

2

1

1

0

3

2

P2

3

2

3

1

6

4

P3

5

0

0

0+(6-1)=5

10

10

 

Total wait time =6 
Total turn around time =20
Average wait time=6/3=2
Average turn around time=20/3=6.66


 Consider the following set of processes with the length of CPU  burst time and arrival time given in milli seconds

 

 

Process

Burst Time

Arrival Time

Priority

P1

3

1

3(highest)

P2

2

2

2

P3

5

0

1

 

Illustrate the execution of these process using non-premptive priority CPU Scheduling algorithems. Also calculate wait time and turn around time of each process and calculate average waiting time and average turn around time for above situation.

 

 Solution :

Process

(1)

Burst Time

(2)

Arrival Time

(3)

Priority

Start Time

(4)

Wait Time

(5)

(4)-(3)

 

Finish Time

(6)

(4)+(2)

Turn Around Time

(7)

(6)-(3)

P1

3

1

  3

5

4

8

7

P2

2

2

2

8

6

10

8

P3

5

0

1

0

0

5

5

Total wait time= 10

Average Wait time =10/3=3.33

 

Total Turn around time = 20

average turn around time=20/3=6.66
 

 

 Assume there are three free frames , find out belady's anomaly for 4 free frames, If reference string is 1,2,3,4,1,2,5,1,2,3,4,5. Use LRU

 

Solution

 

RS

1

2

3

4

1

2

5

1

2

3

4

5

F1

1

1

1

4

4

4

5

5

5

3

3

3

F2

 

2

2

1

1

1

1

1

1

1

4

4

F3

 

 

3

3

3

2

2

2

2

2

2

5

PF

1

2

3

4

1

2

5

---

----

3

4

5

Total Page Fault = 10

Now page fault for 4 frames

 

RS

1

2

3

4

1

2

5

1

2

3

4

5

F1

1

1

1

1

1

1

1

1

1

1

1

5

F2

 

2

2

2

2

2

2

2

2

2

2

2

F3

 

 

3

3

3

3

5

5

5

5

4

4

F4

 

 

 

4

4

4

4

4

4

3

3

3

PF

1

2

3

4

---

---

5

---

----

3

4

5

Total page fault =8

Hence we can say there is no belady's anomaly.