OS Assignment 3 SSUET, Schemes and Mind Maps of Operating Systems

Operating System Assignment 3 Questions

Typology: Schemes and Mind Maps

2020/2021

Uploaded on 06/19/2023

muhammad-shahwaiz-2
muhammad-shahwaiz-2 🇵🇰

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Question 1
The following pair of processes share a common set of variables: “counter”, “temp A” and “temp B”
Process A Process B
A1: tempA = counter+1; B1: tempB = counter+2;
A2: counter = tempA; B2: counter = tempB;
The variable “counter” initially has the value 10 before either process begins to execute.
(i) What difference values of “counter” are possible when both processes finished executing?
Give an order of execution of statements from process A and B that would yield each of the
values you give. For example, execution order A1, A2, B1, and B2 would yield the value
13.
(ii) Modify the above programs for processes A and B by adding appropriate signal and wait
operations on the binary semaphore “sync” such that the only possible final value of
“counter” is 13. Indicate what should be the initial value of the semaphore “sync”.
Question 2
Reading Assignment: Classical Problems of Synchronization (Dining-Philosophers Problem)
There are two main purposes for this assignment. The first is to provide you with the opportunity to
explore a working of algorithm. A second purpose is to provide you with the opportunity to develop and
practice your skills in critical reading and thinking.
Course Instructors:
ENGR. FARHEEN QAZI, ENGR. SYED HARIS MEHBOOB & MS. FALAK SALEEM
SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY
SOFTWARE ENGINEERING DEPARTMENT
SPRING 2023
OPERATNG SYSTEMS (SE-204T)
Assignment 3
Semester: IV Batch: 2021F
Due Date: 20/6/2023 Max Marks: 10
Instructions:
Solution must be Hand Written and8submitted in form of Hardcopy otherwise not
accepted.
Assignment must be submitted in Group (4 max.).
Late Submissions will not be acknowledged.
pf3

Partial preview of the text

Download OS Assignment 3 SSUET and more Schemes and Mind Maps Operating Systems in PDF only on Docsity!

Question 1 The following pair of processes share a common set of variables: “counter”, “temp A” and “temp B” Process A Process B A1: tempA = counter+1; B1: tempB = counter+2; A2: counter = tempA; B2: counter = tempB; The variable “counter” initially has the value 10 before either process begins to execute. (i) What difference values of “counter” are possible when both processes finished executing? Give an order of execution of statements from process A and B that would yield each of the values you give. For example, execution order A1, A2, B1, and B2 would yield the value

(ii) Modify the above programs for processes A and B by adding appropriate signal and wait operations on the binary semaphore “sync” such that the only possible final value of “counter” is 13. Indicate what should be the initial value of the semaphore “sync”. Question 2 Reading Assignment : Classical Problems of Synchronization ( Dining-Philosophers Problem ) There are two main purposes for this assignment. The first is to provide you with the opportunity to explore a working of algorithm. A second purpose is to provide you with the opportunity to develop and practice your skills in critical reading and thinking. Course Instructors:

SIR SYED UNIVERSITY OF ENGINEERING & TECHNOLOGY

SOFTWARE ENGINEERING DEPARTMENT

SPRING 2023

OPERATNG SYSTEMS (SE-204T)

Assignment 3 Semester: IV Batch: 2021F Due Date: 20/6/2023 Max Marks: 10 Instructions:  Solution must be Hand Written and submitted in form of Hardcopy otherwise not accepted.  Assignment must be submitted in Group (4 max.).  Late Submissions will not be acknowledged.

Question 3 Consider the following data of a system has five processes (P0, P1, P2, P3 and P4) and four types of resources (A, B, C and D). There are multiple resources of each type. Is the following state safe or not? If it is, show how the processes can complete. If not, show how they can deadlock. Processes Allocation Maximum Available A B C D A B C D A B C D P0 0 0 1 2 0 0 1 2 1 5 2 0 P1 1 0 0 0 1 7 5 0 P2 1 3 5 4 2 3 5 6 P3 0 6 3 2 0 6 5 2 P4 0 0 1 4 0 6 5 6 Question 4 Draw the resource-allocation graph when the sets Process, Resource, and Edges are: P = {T1, T2, T3, T4} R = {A, B, C, D} E = {T1B, AT1, AT2, BT2, T3B, CT3, T2C, T4C, DT3 and DT4} Assume there exists two instances of resource A and one instance of resource B, C and D. As well, assume resources A, B, C and D are non-preemptive and cannot be shared. (i) Draw wait-for-graph with the help of resource allocation graph. (ii) Could a deadlock exist in the system? Briefly explain. Question 5 A disk system has 250 cylinders, numbered 300 to 550. Assume that the read / write head is at cylinder 400 and determine the order of head movement for each algorithm to satisfy the following stream of requests. For comparison purposes, calculate the total head travel distance. They are listed in the order received. 450, 510, 345, 410, 545, 330, 495, 395, 475, 380, 529, 251, 365 Discuss the following algorithms and briefly explain which algorithm is best. (i) LOOK, (ii) SSTF, (iii) C-SCAN, (iv) FCFS. Question 6 Please mark whether the following statements are true or false. (i) One way of implementing semaphores on uni-processor machines is by using Peterson’s algorithm. (ii) A critical section is a segment of code that can be executed by more than one process/thread at a time. (iii) Counting semaphores are the most primitive synchronization mechanisms. Course Instructors: