Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

SIR SYED UNIVERSITY OF ENGINEERING AND

TECHNOLOGY
INTRODUCTION TO OPERATING SYSTEM
(SWE 204)

ASSIGNMENT # 3

Submitted by :
Muhammad Fahad Siddiqui (2019-SE-206)
Muhammad Ali Hamza (2019-SE-219)
Muhammad Moiz Bakaseer (2019-SE-221)
Shahzaib Ansari (2019-SE-249)

Submitted to :
Miss Falak Saleem

1
ASSIGNMENT # 3
Question 1 (Solved by 2019-SE-2**)

Suppose we have 64bit logical address with 8KB of page size and size of each entry in the page is 4
Bytes. Calculate the following:
(i) Inner page size.
(ii) Outer page size.
(iii) Page offset

Answer.

Question 2 (Solved by 2019-SE-2**)

Given the following stream of page references by an application, calculate the number of page faults
the application would incur with the FIFO, LRU and Optimal page replacement algorithms. Assume
that there are 3 frames, and all are initially empty. Reference Stream: E D H B D E D A E B E D E B G.

Answer.
Question 3 (Solved by 2019-SE-2**)

(a) 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.

(b) Draw the resource-allocation graph when the sets Process, Resource, and Edges are:
P = {T1, T2, T3, T4} R = {A, B, C, D} E = {T1B, AT1, AT2, BT2, T3B, CT3, T2C, T4C,
DT3 and DT4}
Assume there exists two instances of resource A and D one instance of resource B and C. 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.

Answer.
(a)

(b)

2
Question 4 (Solved by 2019-SE-2**)

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”.

Answer.
Question 5 (Solved by 2019-SE-2**)

This problem was originally based on the Senate bus at Wellesley College. Riders come to a bus stop
and wait for a bus. When the bus arrives, all the waiting riders invoke board Bus, but anyone who
arrives while the bus is boarding must wait for the next bus. The capacity of the bus is 50 people; if
there are more than 50 people waiting, some will have to wait for the next bus. When all the waiting
riders have boarded, the bus can invoke depart. If the bus arrives when there are no riders, it should
depart immediately. Write synchronization code using Semaphore.
Answer.

Question 6 (Solved by 2019-SE-2**)

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.

Answer.

Question 7 (Solved by 2019-SE-2**)

Consider a file system that uses i-nodes to represent files. Disk blocks are 9-KB in size and a pointer
to a disk block requires 4 bytes. This file system has 12 direct disk blocks, plus single, double, and
triple indirect disk blocks. What is the maximum size of a file that can be stored in this file system?

Answer.

3
Question 8 (Solved by 2019-SE-2**)

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) Hardware interrupts can be disabled both from user- and kernel-space.
(iv) Counting semaphores are the most primitive synchronization mechanisms.

Answer.
Question 9 (Solved by 2019-SE-2**)

Briefly explain the following:


(i) Why rotational latency is usually not considered in disk scheduling? How would you modify
SSTF, SCAN, and C-SCAN to include latency optimization?
(ii) Why must the bit map for file allocation be kept on mass storage, rather than in main
memory?
(iii) Consider a system that supports the strategies of contiguous, linked, and indexed allocation.
What criteria should be used in deciding which strategy is best utilized for a particular file?
(iv) How file allocation table (FAT) works? Explain with the help of diagram.
(v) What is the difference between deadlock prevention and deadlock avoidance? What
category does Bankers algorithm fall in and why?

Answer.

You might also like