CS604 Current Final Term Papers 2022
CS604 Current Final Term Papers 2022
Paper#1
22-9-2022
Q#1: How to handle be lady’s anomaly in FIFO (3 marks)
Paper#2
19-9-2022
Mcqs Waqar ki file say
IPC kay tool five (5 marks) midterm page 48
Find the offset (5 marks)
From handouts
Find best fit and worst fit data given tha (5 marks)
Semaphore ka tha spinlock ki definition or update karna tha
given numeric ko (5 marks)
Paper#3
19-9-2022
Mcqs mostly from Junaid file
Types of storage un ko sort kr kay likhna tha kay jho storage most
frequently used hoti hai at the top. (5 marks)
Os multiprogramming single processor kay sath kesa karta hai (5
marks) midterm
If the page-fault rate is very high. This leads to low CPU utilization. The
operating system thinks that it needs to increase the degree of
multiprogramming, because it monitors CPU utilization. Whether it
would be good to add another process or not.. give reason in either
case. (5 marks)
Paper#4
18-9-2022 CS 604
18.09.2022 (8:00 AM)
MCQ Waqar ke b or junaid ke b dunun ma say thay
mostly, 3,4 in say alg say ay Subjective mix up.
Aik semaphore ka tha,
1. Read (pfdf [1], buf -5) is trha ke equation thee batana thaa kay
properly execute ho ge ya ne.
Q#44
Part's and it's function? diagram given
Pi(circle ⭕) and Ri (rectangle) And edges
between Pi and Ri?
Q#46
Paging and segmentation (Table given with some statement
about paging and segmentation) Answer yes or no? clear
concept of segmentation and paging very important topic
Q#47
Related question about semaphore? Repeated
Q#48
Related question about throughput? mid term
Q#49
Input, output and error redirection in Unix/Linux
Q#50
Three Similarities between monitor and critical region?
Handouts page 124,125
Paper#7
21-9-2022 Cs604
Mcqs Junaid , Riz file Moazz file
1:Fork system call say related tha(193
page per answer ha is Ka ) ?
Paper#8
21-9-2022
Cs604 today paper MCQS from past papers
Subjective paper:
1)shortest seek time first ki diagram bnani thi or calculate
krna tha waiting time and average time repeated
2)bounded buffer problem ko define krna tha or syntax
dia hua tha us mai mistakes check krni thi repeated
3)wait for graph bnana tha repeated
Paper#9
20-9-2022 Cs604
20.9.2022 at 5pm
40 mcq
80 prcnt from wqar file
Directories Segmentation Fragmentation
Cpu scheduler Deadlock
Short or long question
Paper#10
19-9-2022
Cs604
Subjective
Deadlock techniques
Page table
1 numerical from lectures 32
Paper#12
25-03-2022
While managing computer system hardware efficiently,
sometimes it seems reasonable to service all requests that are
close to current head position identify the technique which will
work on this policy. (3 marks)
If it is not possible to find a safe sequence after running safety
algorithm for requesting purpose. What does it mean? (3
marks)
Paper#13
10 sept 20202 Cs604..Current Final ppr
11 mcqs moaz r waqar file mn sy
thy..baki bhi easy thy.. 5 qs 3 mrks
k r 5 qs 5 mrks k thy
Paper#14
3 sept 2022
cs604 9:30 3 sep
How process share memory in segments
Determine the page size: This is the size of the page in bytes. It is
typically a power of 2 and is specified by the operating system.
Split the logical address into two parts: The most significant bits
represent the page number, while the least significant bits represent the
page offset.
Calculate the page number: To do this, take the most significant bits of
the logical address and convert them to a decimal number. This decimal
number represents the index of the page in the page table.
Calculate the page offset: To do this, take the least significant bits of the
logical address and convert them to a decimal number. This decimal
number represents the offset within the page.
For example, let's say we have a system with a page size of 4KB (4096
bytes) and a logical address of 0x12345678. To find the page number
and page offset, we would follow these steps:
Paper#17
6 sept 2021
Source code to executable code steps
File protection
UNIX/LINUX may virtual memory ka concept, esa kuch
question tha
Page replacement (algorithms)
Paged segmentation
Logical to physical address translations(steps)
Deadlock prevention me safe state essential hai ya nahi
Ek table me values thi uss may say average wait time or
first come first serve algorithm say calculation karni thi.
Values di hoi thi uska gant chart banana tha.
Segmentation kay 2 registers kay name.
Paper#18
1 sept 2021
80% MCQS from past moaz file Name of three deadlock
method Access class mode user
Long 3 Similarities Critical region and monitoring region?
Enlist Bits of protection?
Paper#19
31 august 2021
Virtual memory is extremely large than main memory.
It’s yes it not justify your answer.
Deadlock avoidance.
Paper#20
Kinds of semaphores
Stack: In a demand paged environment, using a stack to allocate and deallocate memory is generally a good choice. This is
because the stack is a Last-In-First-Out (LIFO) data structure, which allows for efficient memory allocation and
deallocation. When a new page is needed, it can be easily added to the top of the stack, and when a page is no longer
needed, it can be quickly removed from the top of the stack.
Hash table: In a demand paged environment, using a hash table can be both good and bad. On the one hand, hash tables
provide fast lookup times, which can be beneficial in reducing the amount of page faults. However, hash tables can also be
memory intensive, as they require a significant amount of memory to store the hash table itself and the linked lists that may
be needed to handle collisions. Therefore, the effectiveness of using a hash table in a demand paged environment depends
on the specific implementation and the size of the hash table.
Sequential search: In a demand paged environment, using sequential search is generally a bad choice. This is because
sequential search involves searching through each element of a data structure until the desired element is found. This can
be a slow and inefficient process, particularly if the data structure is large. In a demand paged environment, page faults can
occur frequently, and a slow search algorithm can exacerbate the problem by increasing the time it takes to access the
needed pages. Therefore, using a more efficient search algorithm, such as binary search, is typically a better choice.
Q2: Consider a scenario of demand paging system with the following utilizations:
CPU = 10 %
A.
Paging disk = 95%
B.
Other I/O devices = 3%
C.
You are required to identify the situation of system by considering the above parameters and which of the
following parameter will contribute to improve CPU utilization? Justify them. .
1. Install a faster CPU
2. Introduce page replacement algorithms
3. Increase degree of multiprogramming
4. Increase hard disk storage
5. Decrease degree of multiprogramming
6. Install more main memory
To improve CPU utilization in this scenario, one possible solution would be to increase the amount of main memory
available to the system. By doing so, the frequency of page faults would decrease, and the system would spend less time
swapping pages in and out of memory. This would lead to faster access times for the CPU, which would result in a higher
CPU utilization. Therefore, option 6 (install more main memory) is the parameter that would contribute to improving CPU
utilization in this scenario.
Option 1 (install a faster CPU) would not necessarily improve CPU utilization, as the system is already experiencing a low
load on the CPU. Increasing the speed of the CPU would not necessarily speed up page operations.
Option 2 (introduce page replacement algorithms) could help to reduce the frequency of page faults, but it would not
necessarily improve CPU utilization.
Option 3 (increase degree of multiprogramming) could potentially improve CPU utilization by allowing the system to run
more processes simultaneously, but it would not necessarily address the underlying issue of frequent page faults.
Option 4 (increase hard disk storage) would not necessarily improve CPU utilization, as the system is already experiencing a
high load on the paging disk. Adding more storage would not necessarily speed up page operations.
Option 5 (decrease degree of multiprogramming) could potentially reduce the load on the system, but it would also reduce
the amount of work the system can do at any given time, and it would not necessarily address the underlying issue of
frequent page faults.
Q:3 Consider a swapping system in which memory consists of the following hole sizes in memory
order: 10KB, 4 KB, 20 KB, 18 KB, 7 KB, 9 KB, 12 KB, and 15 KB. Which holes is taken for
successive segment requests of: (a) 12 KB (b) 10 KB (c) 9 KB For best fit and worst fit?
We can solve this problem using the best fit and worst fit memory allocation algorithms.
Best fit: 9KB , 10KB, 12KB
Worst Fit: 12KB, 10KB, 9KB
Q:4 You have studied the concepts of semaphore in details. Answer the following questions. Classify the
semaphores into at least two categories based on waiting behavior. And when a specific semaphore is
more useful as compared to other.
Semaphores can be classified into two categories based on their waiting behavior:
Blocking semaphores: A blocking semaphore, also known as a binary semaphore, blocks the calling process until the
semaphore is available. If the semaphore is not available, the process is put into a waiting queue until it becomes available.
Once the semaphore is released, one waiting process is allowed to proceed.
Non-blocking semaphores: A non-blocking semaphore, also known as a counting semaphore, does not block the calling
process if the semaphore is not available. Instead, the process simply returns an error code and continues executing. Non-
blocking semaphores are typically used for synchronization between processes or threads.
When a specific semaphore is more useful than the other depends on the specific use case. Blocking semaphores are
typically used in situations where mutual exclusion is required, such as protecting a critical section of code from concurrent
access by multiple processes or threads. Non-blocking semaphores, on the other hand, are typically used in situations
where multiple processes or threads need to access a shared resource concurrently, and a blocking semaphore would
cause unnecessary delays and reduce performance .In general, blocking semaphores are more useful when there is a need
for mutual exclusion, and non-blocking semaphores are more useful when there is a need for coordination and
synchronization between multiple processes or threads.
Q:5 Consider the following table for 2 resources and 4 processes. Identify whether system is in safe state
or not? If yes then determine the safe sequence from given information.
Current Allocation Max Available Need
A B A B A B A B
P0 2 0 2 4 2 7 0 4
P1 3 2 9 2 6 0
P2 1 1 4 1 3 0
P3 1 2 6 4 5 2
In Linux operating system, you are required to write down the working of copy on write technique with
respect to virtual memory.
We can use the banker's algorithm to determine whether the system is in a safe state.
First, we calculate the total resources available in the system by adding up the current allocation and the available
resources.
A=2+3+1+1=7
B=0+2+1+2=5
Using the banker's algorithm, we can see that the system is in a safe state and the safe sequence is P1, P3, P2, P0.
Copy on write (COW) is a technique used in virtual memory to conserve memory by sharing pages of memory
between processes. In COW, when a process requests a new page of memory, the operating system creates a copy of
the page, but the copy is not immediately created. Instead, the page is marked as read-only and shared between the
requesting process and the original process that owns the page.
Q: 6In dining philosopher problem, assume that all five philosophers get hungry at the same then all
will pick up their right chopstick and everyone will be waiting for his/her left chopstick. In that case, no
one will get the left chopstick and they will get starve. This problem will create deadlock situation.
Many remedies have been suggested to resolve this deadlock problem. You are required to give at least
three solutions for such type of problem.
Here are three possible solutions to avoid deadlock in the dining philosopher problem:
1. Resource hierarchy solution: Assign an order or priority to the chopsticks, such as a numbering system or
a hierarchy based on the seating arrangement. Each philosopher must pick up the lower-numbered
chopstick first before picking up the higher-numbered chopstick. This eliminates the possibility of a
circular wait and guarantees that the resources will be allocated in an orderly fashion.
2. One chopstick as shared resource: Instead of each philosopher holding two chopsticks, allow the
philosophers to share a common chopstick between two adjacent philosophers. This solution eliminates
the possibility of circular wait as no two adjacent philosophers can pick the common chopstick at the
same time.
3. Timeout solution: Set a timer for each philosopher while waiting for the chopstick. If a philosopher
cannot acquire both chopsticks within a specified time, they release the chopsticks and return to
thinking state. This ensures that no philosopher starves and all get an equal opportunity to eat.
Q:7 Consider a scenario when a process does not have adequate pages because the page-fault rate is very
high. This situation leads to low CPU utilization. Will CPU utilization decreases due to high page fault rate?
Justify your answer
CPU utilization can decrease due to a high page fault rate because when a process requires a page that is not present in
physical memory, a page fault occurs. The operating system then has to load the required page from the disk into physical
memory, and the process has to wait until the page is loaded. This waiting time reduces the CPU utilization because the
CPU is not executing any instructions during this time.
If the page-fault rate is very high, it means that the process is experiencing a large number of page faults, which translates
to a longer waiting time for the required pages to be loaded. As a result, the CPU has to wait for a longer time for the
process to resume execution, leading to a decrease in CPU utilization.
Q8: Name three schemes that allow efficient implementation of page table?
There are several schemes that can be used to efficiently implement page tables in operating systems. Three of the most
commonly used schemes are:
1. Hierarchical Page Tables: In hierarchical page tables, the page table is divided into multiple levels, with each level
having a smaller size than the previous level. Each level of the page table contains a page directory or page table, and
the page directory or table entries point to the next level of the page table. This scheme is efficient because it allows the
page table to be stored in a smaller space and requires fewer memory accesses to find a page table entry.
2. Inverted Page Tables: In inverted page tables, instead of having a page table for each process, a single page table is
used for all processes in the system. The page table contains entries for each physical page frame, and each entry
contains information about the process that owns the page frame and the virtual address range mapped to the page
frame. This scheme is efficient because it reduces the amount of memory required to store page tables and reduces the
time required to search for a page table entry.
3. Multi-level Page Tables: Multi-level page tables are similar to hierarchical page tables, but they use multiple levels of
page tables of the same size. Each page table entry points to another page table, and the last level of the page table
points to the physical page frame. This scheme is efficient because it allows the page table to be divided into smaller
tables, which reduces the amount of memory required to store the page table and speeds up the search for a page table
entry.
Paper#22
You are required to identify the problems in case of following three
piece of code.
P0 P1
signal(S); wait(S);
... ...
wait(S); signal(S);
... ...
b)
P0 P1
wait(S); wait(Q);
wait(Q); wait(S);
... . ..
signal(S); signal(Q);
signal(Q); signal(S);
c)
P0 P1
wait(S); wait(S);
... ...
wait(S); signal(S);
... ...
If it is not possible to find a safe sequence after running the safety
algorithm for a requesting process then what does it means?
a) There is a potential deadlock situation. If P0 executes the signal(S)
operation before P1 executes the wait(S) operation, then P1 will be
blocked indefinitely. Similarly, if P1 executes the wait(S) operation
before P0 executes the signal(S) operation, then P0 will be blocked
indefinitely.
b) There is a potential deadlock situation. If P0 executes the wait(S)
operation before P1 executes the wait(Q) operation, and P1 executes
the wait(S) operation before P0 executes the wait(Q) operation, then
both processes will be blocked indefinitely. This is known as a circular
wait condition.
c) This code segment does not have any apparent problems as it
involves mutual exclusion. The wait() and signal() operations are in the
correct order and there is no potential for deadlock. However, the
exact context of this code segment should be analyzed to ensure that
it is being used correctly.
It means system is not in stable. This system will not end as a safe
system and there will be deadlock.
Let us consider a page size of 16 bytes and process address space of
32 pages and physical address space of 64 frames. Calculate the
following.
a) Number of bits needed for ‘p’.
b) Number of bits needed for ‘f’.
c) Number of bits needed for ‘d’.
Consider a system with 4 processes and 4 resources with single
instance of each resource type. Given below is the Resource Allocation
graph. You are required to construct wait-for graph from Resource
Allocation graph and find out whether the deadlock exists or not?