MCS-041 ASSIGNMENT SOLUTION (2020-21)

Q1. Assume you have the following jobs to execute with one processor :

 Process Processing Time(milli-sec) P1 10 P2 09 P3 02 P4 03 P5 11

All the processes arrived at the same time. Calculate the turnaround time, waiting time, average turnaround time, average waiting time, throughput and processor utilization for the above given set of processes shown in the table, with the length of CPU burst time given in milliseconds using FCFS, SJF, RR (with quantum 2) and SRTN scheduling algorithms. Also draw their corresponding Gantt charts.

First Come First Serve (FCFS)

Waiting Time = Starting Time - Arivel Time
Turnaround Time = Waiting Time + Execution Time

ProcessProcessing TimeWaiting TimeTurnaround Time
P1100(0 + 10) = 10
P209(0 + 10) = 10(10 + 9) = 19
P302(0 + 19) = 19(19 + 2) = 21
P403(0 + 21) = 21(21 + 3) = 24
P511(0 + 24) = 24(24 + 11) = 35

Average Waiting Time = (0 + 10 + 19 + 21 + 24) / 5 = 14.8
Average Turnaround Time = (10 + 19 + 21 + 24 + 35) / 5 = 21.8

Gantt Chart of FCFS

Execute TimeRunning ProcessProcess QueueDescription
0
 P1
 P2 P3 P4 P5
All Processes are arrives at the same time and "P1" gets processed
10
 P2
 P3 P4 P5
"P1" gets completed, so "P2" gets processed
19
 P3
 P4 P5
"P2" gets completed, so "P3" gets processed
21
 P4
 P5
"P3" gets completed, so "P4" gets processed
24
 P5
-"P4" gets completed, so "P5" gets processed
35--"P5" gets completed

Shortest Job First (SJF)

ProcessProcessing TimeWaiting TimeTurnaround Time
P3020(0 + 2) = 2
P403(0 + 2) = 2(2 + 3) = 5
P209(0 + 5) = 5(5 + 9) = 14
P110(0 + 14) = 14(14 + 10) = 24
P511(0 + 24) = 24(24 + 11) = 35

Average Waiting Time = (0 + 2 + 5 + 14 + 24) / 5 = 9
Average Turnaround Time = (2 + 5 + 14 + 24 + 35) / 5 = 16

Gantt Chart of SJF

Execute TimeRunning ProcessProcess QueueDescription
0
 P3
 P1 P2 P4 P5
All Processes are arrives at the same time and "P3" gets processed
2
 P4
 P1 P2 P5
"P3" gets completed, so "P4" gets processed
5
 P2
 P1 P5
"P4" gets completed, so "P2" gets processed
14
 P1
 P5
"P2" gets completed, so "P1" gets processed
24
 P5
-"P1" gets completed, so "P5" gets processed
35--"P5" gets completed

Round Robin (RR)

ProcessProcessing TimeWaiting TimeTurnaround Time
P11021(21 + 10) = 31
P20923(23 + 9) = 32
P3024(4 + 2) = 6
P40312(12 + 3) = 15
P51124(24 + 11) = 35

Average Waiting Time = (21 + 23 + 4 + 12 + 24) / 5 = 16.8
Average Turnaround Time = (31 + 32 + 6 + 15 + 35) / 5 = 23.8

Gantt Chart of RR

Execute TimeRunning ProcessProcess QueueDescription
0
 P1
 P2 P3 P4 P5
All Processes are arrives at the same time and "P3" gets processed
2
 P2
 P3 P4 P5 P1
Quantum time expires, so "P1" is forced out of CPU and "P2" gets processed
4
 P3
 P4 P5 P1 P2
Quantum time expires, so "P2" is forced out of CPU and "P3" gets processed
6
 P4
 P5 P1 P2
"P3" gets completed, so "P4" gets processed
8
 P5
 P1 P2 P4
Quantum time expires, so "P4" is forced out of CPU and "P5" gets processed
10
 P1
 P2 P4 P5
Quantum time expires, so "P5" is forced out of CPU and "P1" gets processed
12
 P2
 P4 P5 P1
Quantum time expires, so "P1" is forced out of CPU and "P2" gets processed
14
 P4
 P5 P1 P2
Quantum time expires, so "P2" is forced out of CPU and "P4" gets processed
15
 P5
 P1 P2
"P4" gets completed, so "P5" gets processed
17
 P1
 P2 P5
Quantum time expires, so "P5" is forced out of CPU and "P1" gets processed
19
 P2
 P5 P1
Quantum time expires, so "P1" is forced out of CPU and "P2" gets processed
21
 P5
 P1 P2
Quantum time expires, so "P2" is forced out of CPU and "P5" gets processed
23
 P1
 P2 P5
Quantum time expires, so "P5" is forced out of CPU and "P1" gets processed
25
 P2
 P5 P1
Quantum time expires, so "P1" is forced out of CPU and "P2" gets processed
27
 P5
 P1 P2
Quantum time expires, so "P2" is forced out of CPU and "P5" gets processed
29
 P1
 P2 P5
Quantum time expires, so "P5" is forced out of CPU and "P1" gets processed
31
 P2
 P5
"P1" gets completed, so "P2" gets processed
32
 P5
-"P2" gets completed, so "P5" gets processed
34
 P5
-As there is no process in the queue, so "P5" gets processed
35--"P5" gets completed

Shortest Remaining Time Next (SRTN)

ProcessProcessing TimeWaiting TimeTurnaround Time
P3020(0 + 2) = 2
P403(0 + 2) = 2(2 + 3) = 5
P209(0 + 5) = 5(5 + 9) = 14
P110(0 + 14) = 14(14 + 10) = 24
P511(0 + 24) = 24(24 + 11) = 35

Average Waiting Time = (0 + 2 + 5 + 14 + 24) / 5 = 9
Average Turnaround Time = (2 + 5 + 14 + 24 + 35) / 5 = 16

Gantt Chart of SRTN

Execute TimeRunning ProcessProcess QueueDescription
0
 P3
 P1 P2 P4 P5
All Processes are arrives at the same time and "P3" gets processed
2
 P4
 P1 P2 P5
"P3" gets completed, so "P4" gets processed
5
 P2
 P1 P5
"P4" gets completed, so "P2" gets processed
14
 P1
 P5
"P2" gets completed, so "P1" gets processed
24
 P5
-"P1" gets completed, so "P5" gets processed
35--"P5" gets completed

Q2. What is a critical section problem? Using C programming, write a semaphore based solution for sleeping barber’s problem and explain the program.

Q3. What is the need of Page Replacement? Consider the following reference string :

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 6, 7, 0, 1, 2, 4, 5, 4, 3

Find the number of page faults with FIFO, Optimal page replacement and Least Recently Used(LRU) with four frames which are initially empty. Check which algorithm gives the minimum no. of page faults?

Q4. a) Give memory partition of 100K ,500K, 200K, 300K and 600K (in order).How would each of the first fit, best fit and worst fit algorithm place process of 212 K, 417 K, 112K, and 426 K(in order)? Which algorithm makes the most efficient use of memory?

Q4. b) What is disk scheduling? Explain the C-SCAN scheduling by giving an example.

Answer : - File systems must be accessed in an efficient manner, especially with hard drives, which are the slowest part of a computer. As a computer deals with multiple processes over a period of time, a list of requests to access the disk builds up. For efficiency purposes, all requests (from all processes) are aggregated together. The technique that the operating system uses to determine which requests to satisfy first is called disk scheduling.

C-SCAN Disk Scheduling

In C-SCAN algorithm, the arm of the disk moves in a particular direction servicing requests until it reaches the last cylinder, then it jumps to the last cylinder of the opposite direction without servicing any request then it turns back and start moving in that direction servicing the remaining requests.

Example
Consider the following disk request sequence for a disk with 200 tracks
65, 48, 39, 08, 99, 164, 152, 38, 124

Q4. c) Explain the FCFS disk scheduling algorithm. Find out the no. of head movements for FCFS for a queue from 0-199 and current header is at 53.

92, 180, 35, 123,16, 121, 60, 65

Answer : - Solve it Yourself

FCFS Disk Scheduling Example → Question 3

Q5. Discuss in detail the Process management, Memory management, I/O management and File management for the Android 10.0 Operating System.

Answer : - MCS-041 Assignment 2018-19 → Question 5

Q6. Lamport’s Bakery Algorithm provides a decentralised implementation of the “take a number” idea. Write and explain this algorithm for Distributed systems.

QuestionSolves.com is an educational website that helps worldwide students in solving computer education related queries.

Also, different software like Visual Studio, SQL Server, Oracle etc. are available to download in different versions.

Moreover, QuestionSolves.com provides solutions to your questions and assignments also.

MORE TOPIC

WHAT WE DO