Operating Systems Midterm Exam Guide
Operating Systems Midterm Exam Guide
Thread pools offer the benefit of faster request servicing because they use existing threads rather than creating new ones. They also limit the number of concurrent threads in an application by bounding it to the pool size, which helps in managing system resources efficiently and preventing over-subscription of CPU resources .
If the time quantum in Round Robin scheduling is too short, the system experiences high overhead due to frequent context switches. If the time quantum is too long, it effectively turns into a First-Come-First-Serve (FCFS) scheduling, causing long wait times for shorter processes if a long-running process executes first. This conundrum highlights the importance of choosing an optimal time quantum for a balanced approach .
SJF scheduling is difficult to implement because it requires knowledge of future CPU burst durations, which is inherently unknowable until processes are executed. In practice, approximations are made using predictions based on historical data, employing techniques like exponential averaging to estimate the length of future bursts based on observed past bursts, thus allowing the scheduler to make more informed decisions .
Operating systems protect CPU resources by implementing timers and using time-sharing. When a timer reaches zero, an interrupt is generated, causing a context switch to prevent any single process from monopolizing the CPU. Memory protection is ensured through the use of base and limit registers, which restrict the memory addresses a process can access, thus preventing one process from accessing the memory space of another .
In a multi-threaded process, heap memory and global variables are shared across threads. Register values and stack memory are not shared because different threads can execute different parts of a program; each thread thus requires its own execution state and stack space to manage its local variables and function calls .
The goals of multi-programming are to increase CPU utilization and keep the CPU busy by efficiently managing multiple programs. Time-sharing aims to provide interactivity and reduce response times by allowing multiple users to interact with a computer at the same time. While multi-programming is geared towards maximizing resource use and keeping the CPU fed with tasks, time-sharing focuses on ensuring that user interactions are timely and responsive, effectively sharing the CPU's time between different interactive tasks .
An API enhances portability by providing a consistent programming interface across different operating systems, regardless of the underlying implementation or hardware. This consistency allows programs to be recompiled rather than rewritten when run on different systems, minimizing the effort required to adapt software across platforms .
In preemptive scheduling, the operating system can interrupt and replace a running process based on priority or time slicing, allowing greater control over resource allocation. Non-preemptive scheduling allows a process to continue running once it has the CPU until it voluntarily yields or is blocked, which can lead to inefficient resource use if a low-priority, long-running process occupies the CPU. The choice between these approaches often depends on the desired balance between system utilization and response time .
The micro-kernel approach is safer as it minimizes the kernel's size, which can reduce bugs. Most components run in user space, so their crashes don't affect the entire system. However, it suffers from poor performance due to slow message-passing communication between components, as opposed to the faster function calls within a monolithic kernel .
Message passing is naturally synchronized and allows communication across machines but is slower due to the overhead of passing messages. Shared memory offers speed advantages since processes can directly read and write to memory, but it requires careful synchronization mechanisms to prevent concurrent access issues and does not support communication across different machines .