Operating System Exam Paper 2022
Operating System Exam Paper 2022
The operating system distinguishes between executing its own code and user-defined code through the use of different modes of operation, typically user mode and kernel mode. In kernel mode, the operating system executes its privileged instructions with unrestricted access to hardware resources. When a system call or an interrupt occurs, the system switches from user mode to kernel mode, allowing the operating system to perform its operations. This separation ensures that user applications do not have direct access to critical system resources, preventing potential damage or security breaches .
Inverted page tables provide a space-saving alternative to traditional page tables by reducing page table entries to the number proportional to frames rather than pages. Each entry contains information about a single page frame. However, this design complicates page lookup processes, leading to slower access times due to a need for searching. Thereby, they are often supplemented with hash tables or other structures to improve lookup speed .
A race condition occurs when two or more processes can access shared data and their execution order affects the program's outcome, leading to inconsistent results. For instance, consider a banking system where two processes simultaneously withdraw funds from the same account balance. If the balance is read simultaneously by both processes before the update, both transactions might pass checks for available funds, resulting in an overdrawn account .
The long-term scheduler, also known as the admission scheduler, determines which processes are to be admitted to the ready queue, thus controlling the degree of multiprogramming. The medium-term scheduler handles swapping processes in and out of the memory to balance load and reclaim memory spaces. The short-term scheduler, or CPU scheduler, is responsible for selecting which process should be executed next by the CPU. It operates more frequently than the other two, aiming to maximize CPU utilization and system responsiveness .
The working set model minimizes thrashing by tracking the set of pages actively used by a process. By ensuring that each process has enough frames to hold its working set to avoid frequent page swapping, it keeps the system stabilized and efficient. By dynamically adjusting based on a process's behavior, it allows maximum processes to execute concurrently without degradations that occur when excessive paging activity overwhelms system resources .
The Readers-Writers problem addresses the conflict between reader and writer processes accessing a shared resource, such as a database. Readers can read simultaneously without conflict, but writers require exclusive access. The problem's challenge lies in ensuring that no writer starves for resource access while also optimizing reader throughput. Solutions must balance these competing access needs efficiently, making it a classical example in studying process synchronization .
A multi-threaded process is one where multiple threads within the same process can run concurrently. Each thread shares resources such as memory and file handles but operates independently. For example, in a web server, different threads handle different requests. This allows threads to perform input/output simultaneously while sharing data, improving CPU utilization and application performance .
Page faults occur when a process attempts to access a page not currently in memory. When a page fault is triggered, the operating system checks if the memory access is valid, and if so, locates the page on disk, loads it into RAM, possibly swapping existing pages back to disk. This process includes updating the page table and resuming process execution seamlessly to the user to maintain system stability and performance .
In process management, the operating system is responsible for creating and deleting both user and system processes, scheduling processes, and providing mechanisms for process synchronization and communication. In storage management, the operating system handles activities such as memory allocation and deallocation, managing storage memory hierarchy, and maintaining system integrity by ensuring proper access controls are in place .
A microkernel design minimizes kernel size by running most services, including device drivers and file management, in user space as separate processes, which can increase modularity and stability. Conversely, monolithic designs have extensive services incorporated into the kernel itself, which may improve performance due to fewer context switches but at the cost of reduced modularity and increased risk of system crashes. This distinction affects system reliability, security, and process efficiency, requiring trade-offs depending on the specific use case .