Operating System Assignment
Operating System Assignment
Least Recently Used (LRU): This strategy replaces the page that has not
been used for the longest period of time. It uses a timestamp or counters
to track page usage history.
Optimal Page Replacement: This strategy replaces the page that will not
be used for the longest period in the future. Although it provides the best
performance, it's impractical as it requires future knowledge.
b. Identify the term used to describe the erroneous situation that occurs if
a program in execution references a page that does not exist. [1]
Question 2
Memory: Includes both volatile (RAM) and non-volatile (ROM) storage for
data and instructions currently in use.
Storage: Permanent storage devices like hard drives and SSDs that retain
data when the computer is powered off.
(List the burst times for the processes. Calculate the waiting time based
on the order they are executed.)
b. ii. Calculate the waiting time for Process P5 using Shortest Job First
Algorithm. [3]
(Analyze the burst times and determine the order for the Shortest Job First
approach.)
b. iii. Calculate the average time the CPU is busy executing these
processes. [2]
Question 3
Shortest Seek Time First (SSTF): Selects the request that is closest to the
current position of the disk arm. This reduces the average wait time but
can lead to starvation for distant requests.
Elevator (SCAN): The disk arm moves in one direction servicing requests
until it reaches the end of the disk and then reverses direction. This
method reduces overall seek time by ensuring both ends are serviced.
C-SCAN (Circular SCAN): Similar to SCAN, but when the arm reaches one
end, it jumps back to the other end without servicing any requests during
the return trip. This provides a more uniform wait time.
d. Describe two virtual memory page fetch policies. Which is less common
in practice? Why? [2]
Demand Paging: Pages are loaded into memory only when they are
needed. This reduces memory usage but can lead to higher page fault
rates.
e. Enumerate some pros and cons for increasing the page size. [2]
Pros:
Reduced page table size, as fewer pages are needed for a given memory
size.
Less internal fragmentation for larger processes that utilize page space
efficiently.
Cons:
Increased risk of page faults if processes need data not contiguous with
other necessary pages.
Greater internal fragmentation since larger pages may leave more unused
space in the allocated frames.
Question 4
Question 5
Disk Formatting: Preparing the disk for storage by setting up a file system
and organizing data blocks.
Storage Allocation: Assigning and managing space on the disk for different
files and applications.
ii. Process State: The current status of a process, including states like
running, waiting, ready, or terminated.
c. Can a process make a transition from the ready state to the blocked
state? Why or why not? [2]
No, a process cannot transition directly from the ready state to the
blocked state. It must first be selected for execution and then encounter a
situation (such as waiting for I/O) that causes it to become blocked.
New processes are placed at the end to ensure fairness and prevent
starvation. This approach guarantees that each process receives a fair
amount of CPU time in a cyclic order, promoting a balanced distribution of
processing time among all processes.
e. What is the distinction between user mode and kernel mode? [1]
g. Assume that n processes apply the fully distributed approach for mutual
exclusion in a distributed system. How many messages are required to
enter a critical section? Explain your answer. [3]
Question 6
Calculate the turnaround time for each job based on their order of
execution when using the shortest-job-first scheduling. Compare this with
other methods to determine optimality.
Deadlock may not necessarily occur in this scenario since having one
additional fork allows at least one philosopher to eat while others may still
compete, thereby breaking the cycle of waiting.
c. Explain how access control lists (ACLs) and capability lists are used as
protection mechanisms. [5]
ACLs list what permissions users or groups have on each object, while
capability lists provide users their own list of what they can access and
the actions they can perfor This approach helps enforce security by
ensuring that users can only access resources for which they have explicit
permissions, thus managing and controlling access to critical system
resources efficiently.
Internal fragmentation occurs when memory blocks are allocated, but not
all of the allocated space is used, leading to wasted space within the
blocks. External fragmentation happens when free memory is split into
small, non-contiguous blocks, making it difficult to allocate larger blocks to
new processes. Both types of fragmentation decrease memory utilization
and can lead to increased overhead and wasted resources.
e. Explain two advantages of using binary semaphores to achieve mutual
exclusion among several processes over Peterson’s solution. [4]
Question 7
a. Consider the following sequence of disk track requests 27, 129, 110,
186, 147, 41, 10, 64, 120. Assume initially, the head is at track 30 and
moving in the direction of decreasing track number. Compute the number
of tracks the head traverses using FIFO, SSTF, and Elevator algorithms. [5]
FIFO: Calculate the total distance traversed sequentially through the track
requests.
SSTF: Compute the distance based on servicing the nearest request each
time.
Question 8
Explain their validity and any exceptions that may apply in certain
circumstances. Generally, the first statement is true, while the second is
false; it is possible to have a deadlock-free solution that still allows for
starvation.
Thrashing occurs when a system spends more time paging than executing
processes due to insufficient memory. Detection can be done by
monitoring page fault rates. Recovery involves increasing physical
memory, decreasing the number of active processes, or optimizing
workload to reduce memory pressure.
Save the state of the currently running process, including its CPU registers
and program counter.
Update the process control block (PCB) of the current process to reflect its
new state (e.g., from running to ready). 3. Select the next process to run
from the ready queue based on the scheduling algorithm. 4. Load the
state of the selected process from its PCB, restoring its CPU registers and
program counter. 5. Transfer control to the selected process, allowing it to
resume execution.
Question 9
File Creation: The operating system allows users to create new files and
directories in the file system.
File Deletion: It provides the ability to remove files from the file system
when they are no longer needed.
File System Integrity: The operating system ensures that the file system
remains organized and error-free, managing fragmentation and keeping
track of free and used space.
Waiting Time: The total time a process spends waiting in the queue,
minimizing delays is critical for user satisfaction.
c. Given six memory partitions of 300 KB, 600 KB, 350 KB, 200 KB, 750
KB, and 125 KB (in order). How would the following algorithms place
processes of size 115 KB, 500 KB, 358 KB, 200 KB, and 375 KB (in order)?
i. First-fit: Place the first process into the first partition that is large
enough.
Result: Track assignment details for each process based on available
partitions.