0% found this document useful (0 votes)
48 views

The Superior College, Lahore: Assignment-III - BSSE (Spring 2021)

The document is an assignment for an Operating Systems course consisting of 3 questions. Question 1 asks the student to draw a Gantt chart showing the execution of 4 processes under multi-level queue scheduling. Question 2 provides resource allocation information for 5 processes and asks the student to determine if deadlock exists using Banker's Algorithm. Question 3 asks the student to analyze a resource allocation graph and determine if deadlock exists, explaining their reasoning. The assignment is due on April 14th and must be submitted in Word or PDF format through the learning management system.

Uploaded by

ArSLan CHeEmAa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

The Superior College, Lahore: Assignment-III - BSSE (Spring 2021)

The document is an assignment for an Operating Systems course consisting of 3 questions. Question 1 asks the student to draw a Gantt chart showing the execution of 4 processes under multi-level queue scheduling. Question 2 provides resource allocation information for 5 processes and asks the student to determine if deadlock exists using Banker's Algorithm. Question 3 asks the student to analyze a resource allocation graph and determine if deadlock exists, explaining their reasoning. The assignment is due on April 14th and must be submitted in Word or PDF format through the learning management system.

Uploaded by

ArSLan CHeEmAa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

The Superior College, Lahore

Assignment-III– BSSE (Spring 2021)


Course Title: Operating system Course Code: CS3414 Credit Hours: 4
Instructor: Arshi Iftikhar Programme Name: BSSE
Semester: 5 Batch: Section: All Date:
Time Allowed: Maximum Marks: 20
Student’s Name: Arslan Ahmed Reg. No. Bsem-f16-104
Important Instructions / Guidelines:

 Keep all of your answers as brief as possible.


 Copying of the assignment will result in failure.
 Deadline for assignment submission is 14th Apr, 2021 till 11:59 pm. Late submission is not allowed.
 Assignment should be submitted in word or pdf on LMS.

Question 1 (5 marks)
Apply multi-level queue scheduling on the following processes. Priority of queue1 is greater
than queue2. Queue1 uses round robin (Q=2) and queue2 uses FCFS. Draw the gantt chart
for it.
processes Arrival time Burst time Queue #
P1 0 4 1
P2 0 3 1
P3 0 8 2
P4 10 5 1

Ans:

Gantt chart is below of the question: 

P1 P2 P1 P2 P3 P4 P3
0 2 4 6 7 10 15 20

Question 2 (10 marks)


Use Banker’s algorithm to find whether deadlock exist in the system or not.
There are 5 processes in the system and resources are represented with A, B and C. A has
10 instances, B has 5 instances and C has 7 instances.

Max Allocation
Processes A B C A B C
P0 7 5 3 0 3 0
P1 3 2 2 2 0 0
P2 9 0 2 3 0 2
P3 2 2 2 2 1 1
P4 4 3 3 0 0 2

Ans :

Context of the need matrix is as follows:


Need [i] = Max [i] - Allocation [i]
Need for P0: (7 5 3) - (0 3 0) = 7 2 3
Need for P1: (3 2 2) - (2 0 0) = 1 2 2
Need for P2: (9 0 2) - (3 0 2) = 6 0 0
Need for P3: (2 2 2) - (2 1 1) = 0 1 1
Need for P4: (4 3 3) - (0 0 2) = 4 3 1
Max Allocation Need
Processes A B C A B C A B C
P0 7 5 3 0 3 0 7 2 3
P1 3 2 2 2 0 0 1 2 2
P2 9 0 2 3 0 2 6 0 0
P3 2 2 2 2 1 1 0 1 1
P4 4 3 3 0 0 2 4 3 1

Banker’s algorithm
Now we check if each type of resource request is available for each process.
Need <= Available
If condition is true than we use
(New available = available + Allocation) this condition
Max Allocation Need Available
Processes A B C A B C A B C A B C
P0 7 5 3 0 3 0 7 2 3 3 1 2
P1 3 2 2 2 0 0 1 2 2 5 1 2
P2 9 0 2 3 0 2 6 0 0 7 2 3
P3 2 2 2 2 1 1 0 1 1 7 5 1
P4 4 3 3 0 0 2 4 3 1 10 2 5

Deadlock is not exist in the system.

Question 3 (5 marks)
Determine if there is a deadlock in the graph. Explain why or why not.

Ans:

In this graph dead lock exists because a cycle become exists in the graph. If the cycle is not exist
in graph mean deadlock exist in graph and if in graph cycle is exist mean deadlock may or may
not be exist.
R1 assigned to p1 but p1 request to R3
R1 assigned to P2 but request to R3 same time P1 request to R4. Already P1 assigned and
request to himself so R4 will wait until proceeds 1 terminate
P3 request to R1 but wait occur to due to the previous process same time R4 request to P3 and P3
assigned to R2, R1 will be wait until P3 terminate
Whenever P3 request to R2 same time R2 assigned himself to P4, therefore P3 will wait and R5
also assigned himself to p4..so all process is busy no process is to be alone because all process is
bust no process is released to any process all are in request state or in assigned state.

You might also like