Operating System Fundamentals: Core Concepts Explained
Classified in Electronics
Written on in English with a size of 6.57 KB
Understanding Spooling in Operating Systems
Spooling (Simultaneous Peripheral Operations Online) is a technique used in operating systems to manage I/O operations efficiently. It involves buffering data for various I/O devices, such as printers, in a temporary storage area (usually disk).
- Input Spooling: This technique involves reading jobs (for example, from cards) onto the disk. This ensures that when currently executing processes are finished, work will be waiting for the CPU, maximizing CPU utilization.
- Output Spooling: This consists of first copying printable files to disk before printing them, rather than printing directly as the output is generated. This frees up the CPU and application to perform other tasks while printing occurs in the background.
While input spooling on a personal computer is not very likely, output spooling is a common and standard feature.
Multiprogramming & CPU Utilization Without DMA
On early computers, every byte of data read or written was handled directly by the CPU (without Direct Memory Access - DMA). What implications does this have for multiprogramming?
The primary reason for multiprogramming is to give the CPU something to do while waiting for I/O to complete. If there is no DMA, the CPU is fully occupied doing I/O, meaning it directly manages every data transfer. In such a scenario, there is nothing to be gained (at least in terms of CPU utilization) by multiprogramming. No matter how much I/O a program does, the CPU will be 100% busy with I/O tasks. This, of course, assumes the major delay is the wait while data are copied. A CPU could do other work if the I/O were slow for other reasons, such as device latency.
Contradictory Design Goals in Operating Systems
There are several design goals in building an operating system, for example, resource utilization, timeliness, and robustness. Can you give an example of two design goals that may contradict one another?
Consider fairness and real-time requirements. Fairness requires that each process be allocated its resources in a fair way, with no process getting more than its fair share. On the other hand, real-time requirements dictate that resources be allocated based on the times when different processes must complete their execution. A real-time process may, therefore, get a disproportionate share of the resources to meet its strict deadlines, potentially at the expense of fairness to other processes.
Understanding Trap Instructions in OS
What is a trap instruction? Explain its use in operating systems.
A trap instruction is a special instruction that switches the execution mode of a CPU from the user mode to the kernel mode. This instruction allows a user program to invoke functions in the operating system kernel. Traps are typically used for system calls, error conditions, or debugging.
Trap vs. Interrupt: Key Differences
What is the key difference between a trap and an interrupt?
The fundamental difference lies in their origin and reproducibility:
- A trap is caused by the program itself and is synchronous with it. If the program is run repeatedly, the trap will always occur at exactly the same position in the instruction stream. Traps are often intentional, such as system calls.
- An interrupt is caused by an external event (e.g., I/O completion, timer expiration) and its timing is not reproducible. Interrupts are asynchronous and can occur at any point during program execution.
The Role of the Process Table in OS
Why is the process table needed in a timesharing system? Is it also needed in personal computer systems where only one process exists, taking over the entire machine until it is finished?
The process table is essential in a timesharing system because it is needed to store the state of a process that is currently suspended, either ready to run or blocked (waiting for an event). This allows the operating system to switch between multiple processes, saving and restoring their contexts.
It is generally not needed in a single-process system where that single process takes over the entire machine until it is finished, because the single process is never suspended or swapped out; its state is always active.
Purpose of System Calls in Operating Systems
What is the purpose of a system call in an operating system?
A system call allows a user process to access and execute operating system functions within the kernel. User programs use system calls to invoke operating system services, such as file I/O, process creation, memory management, and inter-process communication. They provide an interface between a user application and the operating system.
Client-Server Model in Single-Computer Systems
The client-server model is popular in distributed systems. Can it also be used in a single-computer system?
Yes, it can. Even within a single computer, different components or processes can interact using a client-server model, especially if the kernel is a message-passing system. For example, a user application (client) might request a service from a local daemon or a kernel module (server).
Programmer Awareness of System Calls
To a programmer, a system call looks like any other call to a library procedure. Is it important that a programmer know which library procedures result in system calls? Under what circumstances and why?
As far as program logic is concerned, it does not matter whether a call to a library procedure results in a system call. The functionality will be the same.
However, it is important for a programmer to know which library procedures result in system calls under circumstances where performance is a critical issue. Here's why:
- Overhead: Every system call involves overhead time in switching from the user context to the kernel context. This context switch is a relatively expensive operation.
- Scheduling: Furthermore, on a multi-user system, the operating system may schedule another process to run when a system call completes, further slowing the real-time progress of a calling process.
Therefore, if a task can be accomplished without a system call (e.g., by using only user-space library functions), the program will generally run faster and more efficiently.