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

Assignment-OS_Module-2

Good

Uploaded by

neerajgautam9548
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)
3 views

Assignment-OS_Module-2

Good

Uploaded by

neerajgautam9548
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/ 5

Assignment Module-2

Course: B.Tech (CSE All) Year/Semester: II/IV Session: 2024-2025


Subject Name & Code: Operating Systems (BCSC0004)
Submission Date:02/05/2025

Q1: Consider the following page reference string. 1,2,3,4,5,3,4,1,6,7,8,7,8,9,7,8,9,5,4,5,4,2 How


many page faults would occur for the following replacement algorithm, assuming 3, 4 and 5
frames respectively?
a. Optimal page replacement. b. LRU page replacement. c. FIFO page replacement

Q2: Free memory holes of sizes 15K, 10K, 5K, 25K, 30K, 40K are available. The processes of
size 12K, 2K, 25K, 20K is to be allocated. How processes are placed in first fit, best fit, worst fit.
Calculate internal as well as external fragmentation.

Q3: Calculate page faults for (LRU, FIFO, OPT) for following sequences where page frame is
three.
0,1,2,1,4,2,3,7,2,1,3,5,1,2,5.

Q4: System snapshot:

a) How many resources are there of type (A, B, C)?


b) What are the contents of the Need matrix?
c) Is the system in a safe state? Why?
d) If a request from process P1 arrives for additional resources of (0, 5, 2), can the Banker's
algorithm grants the request immediately?
e) What would be the new system state after the allocation?

Q5: Consider a system consisting of four resources of the same type that are shared by three
processes, each of which needs at most two resources. Is this system deadlock-free? Why or why
not?
Q6: Consider the following snapshot-

Answer the following questions using banker’s algorithm:


a) What are contents of matrix end?
b) Is the system in safe state?
c) If request for process p1 arrives for (0, 4, 2, 0). Can the request be granted immediately?

Q7. Given 3 processes A, B and C, three resources x,y and z and following events, i) A requests
x ii) A requests y iii) B requests y iv) B requests z v) C requests z vi) C requests x vii) C requests
y Assume that requested resources should always be allocated to the request process if it is
available. Draw the resource allocation graph for the sequences. And also mention whether it is a
deadlock? If it is, how to recover the deadlock.

Q8. A system shares 9 tape drives. The current allocation and maximum requirement of tape
drives for 4 processes are shown below:

Describe the current status of the system as safe or unsafe.

Q9. Describe the SSTF disk scheduling algorithm using the following data. The dist head is
initially at position-cylinder 53.the cylinder sequence of requests is 98, 183, 37, 122, 14, 124, 65.
67. Find the total head movement.

Q10. Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive currently
services a request at cylinder 143, and the previous request was at cylinder 125. the queue of
pending request in FIFO order is 86,1470,913,1774,948,1509,1022,1750,130 Starting from the
current position, what is the total distance(in cylinders) that the disk arm moves to satisfy all
pending requests, for each of the following algorithms i)FCFS ii) SSFT iii) SCAN iv) LOOK v)
C-SCAN.

Q11. The queue of requests in FIFO is 86, 147, 91, 177, 94,150,102,175,130 what is the total
head movement needed to satisfy the requests for the following Scheduling algorithms FCFS,
SJF, SCAN, LOOK, C-SCAN.
Q12. Suppose that the head of moving head disk with 200 tracks numbered 0 to 199 is currently
serving the request at track 143 and has just finished a request at track 125. If the queue request
is kept in FIFO order, 86, 147, 91, 177, 94, 150, 102, 175, 130. What is the total head movement
to satisfy these requests for i) FCFS II) SSTF disk scheduling algorithm

Q13: A system contains three programs and each requires three tape units for its operation. The
minimum number of tape units which the system must have such that deadlocks never arise is
_________.

Q14: Assume that in a certain computer, the virtual addresses are 64 bits long and the physical
addresses are 48 bits long. The memory is word addressable. The page size is 8 kB and the word
size is 4 bytes. The Translation Look-aside Buffer (TLB) in the address translation path has 128
valid entries. At most how many distinct virtual addresses can be translated without any TLB
miss?

Q15: Consider a computer system with 40-bit virtual addressing and page size of sixteen
kilobytes. If the computer system has a one-level page table per process and each page table
entry requires 48 bits, then the size of the per-process page table is __________ megabytes.

Q16: A computer system implements 8 kilobyte pages and a 32-bit physical address space. Each
page table entry contains a valid bit, a dirty bit, three permission bits, and the translation. If the
maximum size of the page table of a process is 24 megabytes, the length of the virtual address
supported by the system is ________ bits.

Q17: Assume that there are 3-page frames which are initially empty. If the page reference string
is 1, 2, 3, 4, 2, 1, 5, 3, 2, 4, 6, the number of page faults using the optimal replacement policy
is__________.

Q18: Consider a paging hardware with a TLB. Assume that the entire page table and all the
pages are in the physical memory. It takes 10 milliseconds to search the TLB and 80
milliseconds to access the physical memory. If the TLB hit ratio is 0.6, the effective memory
access time (in milliseconds) is?

Q19: Consider the virtual page reference string 1, 2, 3, 2, 4, 1, 3, 2, 4, 1 On a demand paged


virtual memory system running on a computer system that main memory size of 3 pages frames
which are initially empty. Find the number of page faults under the corresponding page
replacements policy.: LRU, FIFO and OPTIMAL.

Q20 A system uses FIFO policy for page replacement. It has 4 page frames with no pages loaded
to begin with. The system first accesses 100 distinct pages in some order and then accesses the
same 100 pages but now in the reverse order. How many page faults will occur?

Q21: A process has been allocated 3 page frames. Assume that none of the pages of the process
are available in the memory initially. The process makes the following sequence of page
references (reference string): 1, 2, 1, 3, 7, 4, 5, 6, 3, 1 If optimal page replacement policy is used,
how many page faults occur for the above reference string?
Q22: In a virtual memory system, size of virtual address is 32-bit, size of physical address is 30-
bit, page size is 16 Kbyte and size of each page table entry is 32-bit. The main memory is byte
addressable. Which one of the following is the maximum number of bits that can be used for
storing protection and other information in each page table entry?

Q23: Consider six memory partitions of size 200 KB, 400 KB, 600 KB, 500 KB, 300 KB and
250 KB. These partitions need to be allocated to four processes of sizes 357 KB, 210 KB, 468
KB and 491 KB in that order.

Perform the allocation of processes using-

1. First Fit Algorithm


2. Best Fit Algorithm
3. Worst Fit Algorithm

24. Consider a memory management system that uses a page size of 2 KB2 KB.
Assume that both the physical and virtual addresses start from 0. Assume that the pages
0,1,20,1,2, and 33 are stored in the page frames 1,3,21,3,2, and 00, respectively. The physical
address (in decimal format) corresponding to the virtual address 25002500 (in decimal format) is
____

25. Consider the following two-dimensional array D in the C programming language,


which is stored in row-major order:

int D[128][128];

Demand paging is used for allocating memory and each physical page frame holds 512 elements
of the array D. The Least Recently Used (LRU) page-replacement policy is used by the operating
system. A total of 30 physical page frames are allocated to a process which executes the
following code snippet:

for (int i = 0; i < 128; i++)


for (int j = 0; j < 128; j++)
D[j][i] *= 10;

The number of page faults generated during the execution of this code snippet is _____.

26. Consider the following page reference string.


1 2 3 4 2 1 5 6 2 1 2 3 7 6 3 2 1 2 3 6
What are the minimum number of frames required to get a single page fault for the above
sequence assuming LRU replacement strategy?
27. Consider a paging system that uses 1-level page table residing in main memory
and a TLB for address translation. Each main memory access takes 100 ns and TLB lookup takes
20 ns. Each page transfer to/from the disk takes 5000 ns. Assume that the TLB hit ratio is 95%,
page fault rate is 10%. Assume that for 20% of the total page faults, a dirty page has to be written
back to disk before the required page is read from disk. TLB update time is negligible. The
average memory access time in ns (round off to 1 decimal places) is ___________

28. Determine the number of page faults when references to pages occur in the order
1,2,4,5,2,1,2,4. Assume that the main memory can accommodate 3 pages and the main memory
already has the pages 1 and 2, with page 1 brought earlier than page 2. (assume LRU i.e., Least-
Recently-Used algorithm is applied).

29. Given reference to the following pages by a program


0,9,0,1,8,1,8,7,8,7,1,2,8,2,7,8,2,3,8,3
How many page faults will occur if the program has three page frames available to it and uses an
optimal replacement?

30. Consider a computer system with ten physical page frames. The system is
provided with an accesses sequence (a1,a2,...,a20,a1,a2,...,a20), where each ai is a distinct virtual
page number. The difference in the number of page faults between the last-in-first-out page
replacement policy and the optimal page replacement policy is ______.

You might also like