Q2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Fall 2022

CEN 301: Operating Systems

Quiz 2
Submission Date : 25/11/2022
Due Date : 02/12/2022 23:59
TA : Necva BÖLÜCÜ
Click here to accept your Quiz 2
1. Explain the difference between a preemptive scheduler and a non-preemptive scheduler,
and and give an example of a system in which both could be used.
2. Describe the differences between long-term and short-term scheduling of processes.
3. Draw Gantt charts for scheduling algorithms for the processes specified in Table 1 and
calculate the average turnaround and job waiting time.

Process Arrival Time Burst Time Priority


P1 0 12 2
P2 2 4 3
P3 5 2 1
P4 8 10 4
P5 10 6 5

Table 1: CPU Scheduling

(a) First Come First Serve (FCFS)


(b) Shortest-Job-First (SJF)
(c) Shortest Remaining Time First (SRTF)
(d) Priority Scheduling (non-preemptive)
(e) Priority Scheduling (preemptive)
(f) Round Robin Scheduling (quantum=4)
4. Suppose that we have the following resources: R1, R2, R3, R4 and processes P 0, P 1,
P 2, P 3, and P 4. The total number of instances for each resource is given below. Answer
the following questions for the given Table 2.

Max Allocation Available


R1 R2 R3 R4 R1 R2 R3 R4 R1 R2 R3 R4
P0 6 0 1 2 4 0 0 1 3 2 1 1
P1 2 7 5 0 1 1 0 0
P2 2 3 5 6 1 2 5 4
P3 1 6 5 3 0 6 3 3
P4 1 6 5 6 0 2 1 2

Table 2: Banker Algorithm

(a) How many resources are there in the type of R1, R2, R3 and R4?

Quiz 2 1
Fall 2022
CEN 301: Operating Systems

(b) Calculate the need matrix for the given max and allocation matrices in Table 2.
(c) Find out if the system is in the safe state? If so, find the safe sequence.
5. A system consists of 5 processes {P 1, P 2, P 3, P 4, P 5} and 6 types of resources {R1, R2, R3, R4, R5, R6}.
The number of units of resources is 2 for each resource. There are some resource in-
stances that are already allocated to processes, as follows:
• 1 instance of R1 held by P 1, another held by P 2
• 1 instance of R2 held by P 3
• 1 instance of R3 held by P 3, another held by P 4
• 1 instance of R4 held by P 3
• 1 instance of R5 held by P 3, another held by P 4
• 2 instances of R6 held by P 5
Some processes have requested additional resources, as follows:
• P 1 wants 1 instance of R4
• P 2 wants 1 instance of R1 and 1 instance of R2
• P 3 wants 1 instance of R1
• P 4 wants 1 instance of R6
• P 5 wants 1 instance of R3
(a) Draw the resource allocation graph for this system.
(b) What is the state (runnable, waiting) of each process?
(c) Is this system deadlocked? If not, explain in which order the processes are running.

Important Notes
• Do not miss the submission deadline.
• Save all your work until the quiz is graded.
• All work on quizzes must be done individually unless stated otherwise. You are en-
couraged to discuss with your classmates about the given quizzes, but these discussions
should be carried out in an abstract way. That is, discussions related to a particular
solution to a specific problem (either in actual code or in the pseudocode) will not be
tolerated. In short, turning in someone else’s work, in whole or in part, as your own will
be considered as a violation of academic integrity. Please note that the former condition
also holds for the material found on the web as everything on the web has been written
by someone else.
• You may assume that the input files will be given as:
– quiz2.pdf

Quiz 2 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy