Operating System Basics
- 36Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is an operating system, according to the lecture's analogy?
36 questions
- 1
What is an operating system, according to the lecture's analogy?
Model answer
An operating system is like the electronic court of Versailles, managing the computer's activities behind the scenes so the user (like Louis XIV) experiences smooth operation.
Explanation
The analogy emphasizes that the OS handles complex internal tasks transparently, just as servants managed the court.
- 2
How did early computers (like UNIVAC) operate before operating systems?
Model answer
They used an 'open shop' system where the programmer and user were the same person, operating the console directly with switches.
Explanation
There was no OS to abstract hardware; the user had sole use of the machine and managed all operations.
- 3
Describe the open shop scheduling on the IBM 701 and its inefficiency.
Model answer
Users got 15-minute slots; about 10 minutes were spent setting up tapes and output, leaving only 5 minutes of actual computation. The MTBF was 3.5 hours, so failures were common.
Explanation
This early approach wasted time on manual setup and often faced machine failures.
- 4
How has the goal of operating systems shifted from early computers to today?
Model answer
Early: many users sharing one expensive machine. Today: one user accessing many inexpensive machines to maximize work output.
Explanation
Cost reduction of hardware reversed the optimization target.
- 5
List the phases of operating systems according to Per Brinch Hansen's table.
Model answer
1950s: open shop; 1960s: closed shop/tape batching, multiprogramming; 1970s: time sharing; 1980s: concurrent programming; later: personal computing, distributed systems, and the cloud.
Explanation
These phases track the evolution from single-user manual operation to complex multi-user, interactive, and distributed systems.
- 6
What problem led to the development of context switching?
Model answer
Slow I/O peripherals caused the CPU to sit idle while waiting, so the idea was to switch to another process during waits.
Explanation
Context switching improves CPU utilization by overlapping computation with I/O.
- 7
Explain the process of a context switch.
Model answer
When an interrupt occurs, the OS saves the current process's state (e.g., program counter, registers) into a Process Control Block (PCB), loads the saved state of another process from its PCB, and resumes that process.
Explanation
This allows multiple processes to share the CPU, creating multitasking.
- 8
What is an interrupt in the context of operating systems?
Model answer
An interrupt is a signal to the CPU to suspend its current activity and execute a handler, often used by hardware to request service or by software to trigger a context switch.
Explanation
Interrupts are fundamental for I/O, scheduling, and exception handling.
- 9
What information is typically saved in a Process Control Block (PCB) during a context switch?
Model answer
The PCB typically saves the program counter, all CPU registers, and local memory state of the process.
Explanation
This information is needed to restore the process exactly as it was before interruption.
- 10
How does a thread differ from a process in terms of context switching?
Model answer
A thread (lightweight process) saves less context during a switch because threads within the same process share memory and resources, reducing overhead.
Explanation
Threads are more efficient for concurrent tasks that share data.
- 11
Using the knitting/supper/baby analogy, explain how a stack is used in context switching.
Model answer
When switching tasks, the state of the current task (e.g., knitting pattern) is pushed onto a stack. When that task resumes, it is popped off. Multiple tasks create a stack of saved states.
Explanation
The stack manages nested interrupts and context switches efficiently.
- 12
What is the role of an interrupt controller regarding priority?
Model answer
The interrupt controller evaluates the priority of incoming interrupts and decides whether to allow the interrupt based on the current task's priority.
Explanation
High-priority interrupts (e.g., fire) are handled immediately; lower ones may wait.
- 13
How does a scheduler generate context switches?
Model answer
The scheduler divides CPU time into chunks, then at each chunk boundary it generates a software interrupt to invoke the scheduler, which decides which process to run next.
Explanation
This creates the illusion of simultaneous execution for multiple tasks.
- 14
What are protected instructions and why are they necessary?
Model answer
Protected instructions are those that can only be executed in kernel/supervisor mode, preventing user processes from interfering with each other or the OS.
Explanation
They ensure security and stability by restricting access to critical hardware and data.
- 15
Explain the concept of privilege levels in an operating system.
Model answer
Operating systems define a hierarchy of privileges (e.g., super user vs normal user). The OS runs in privileged mode, while user processes run in user mode with restricted access.
Explanation
This prevents malicious or buggy user code from harming the system.
- 16
What motivates the move from monolithic kernels to microkernels?
Model answer
Microkernels aim to run only the minimal essential functions in privileged mode, reducing the attack surface and enabling formal verification of the kernel's correctness.
Explanation
Smaller kernels are easier to prove correct; e.g., seL4 is a formally verified microkernel.
- 17
What is virtual memory and what illusion does it provide?
Model answer
Virtual memory gives each user the illusion of having a large, private, linear memory space, while physically it maps virtual addresses to physical memory and disk storage.
Explanation
This allows efficient use of memory and protection between processes.
- 18
Describe how paging works in virtual memory.
Model answer
Memory is divided into fixed-size pages. A page table maps virtual pages to physical frames in RAM or to backing store on disk. On a page fault, the required page is loaded from disk into a free frame.
Explanation
Paging enables non-contiguous memory allocation and demand paging.
- 19
What is a page fault and how is it handled?
Model answer
A page fault occurs when a process accesses a page not currently in main memory. The OS fetches the page from disk (backing store) into a free frame, updates the page table, and resumes the process.
Explanation
Page faults are normal but excessive faults can degrade performance.
- 20
What is the role of a cache in the context of paging?
Model answer
A cache stores frequently accessed pages to speed up memory access, mediating between fast RAM and slower disk.
Explanation
Caching reduces latency and avoids repeated page faults.
- 21
Define thrashing in virtual memory systems.
Model answer
Thrashing occurs when the system spends more time swapping pages in and out of memory than doing actual computation, leading to severe performance degradation.
Explanation
It happens when there is insufficient physical memory for active processes.
- 22
What are the three main components of the Unix operating system?
Model answer
The kernel (manages hardware and scheduling), the shell (command interpreter), and utility programs (e.g., editors, sorters).
Explanation
Unix is designed as a small kernel with many user-level utilities.
- 23
Why are standard interface definitions important in operating systems?
Model answer
They allow programs to work across different hardware without modification, as long as the OS provides consistent APIs for device access.
Explanation
This abstraction simplifies software development and portability.
- 24
List the typical functional blocks or layers inside a kernel (as seen in Linux).
Model answer
Device drivers, file systems (virtual file system), networking (IP, TCP), virtual memory, scheduler, and process/user management.
Explanation
These blocks are standard across OS designs, though implementation details differ.
- 25
How does Android relate to Unix?
Model answer
Android uses the Linux kernel, which is a Unix-like OS. Thus Android is built on Unix principles and kernel.
Explanation
Linux dominates mobile OS through Android.
- 26
What is the difference between static and dynamic linking?
Model answer
Static linking includes library code into the executable at compile time; dynamic linking loads libraries at runtime, either when the program starts or on demand (e.g., DLLs).
Explanation
Dynamic linking reduces executable size but can lead to version conflicts ('DLL hell').
- 27
What is just-in-time (JIT) compilation and where is it used?
Model answer
JIT compilation translates code to machine language immediately before execution, combining interpretation speed with compiled performance. It is used in Java and JavaScript engines.
Explanation
JIT enables optimization based on runtime behavior.
- 28
Describe the scheduling algorithm used in Solaris for time-sharing threads.
Model answer
Solaris assigns each thread a priority; higher priority threads run first. After a thread uses its time slice (20 ms), its priority is decreased, moving it to a lower priority queue.
Explanation
This ensures high-priority tasks are serviced promptly but prevents starvation.
- 29
What distinguishes a real-time operating system from a general-purpose one?
Model answer
A real-time OS guarantees that critical tasks complete within a fixed deadline, not just 'fast'. Missing a deadline is considered a system failure.
Explanation
Real-time systems are used in embedded and safety-critical applications.
- 30
Give an example of a race condition in concurrent programming.
Model answer
Two processes both incrementing a shared variable X (initially 0). If they both read X before either writes, both may store 1 instead of the correct 2.
Explanation
Race conditions occur when the outcome depends on the order of execution.
- 31
Explain priority inversion and its consequences.
Model answer
Priority inversion occurs when a high-priority task is blocked waiting for a resource held by a low-priority task. Meanwhile, a medium-priority task can run, causing the high-priority task to miss its deadline.
Explanation
This led to a failure in the Mars rover mission due to deadlock.
- 32
What are the three main cloud service models and give examples of each.
Model answer
SaaS (Software as a Service, e.g., Google Docs), PaaS (Platform as a Service, e.g., AWS, Azure), IaaS (Infrastructure as a Service, virtual servers).
Explanation
Cloud computing shifts physical machine management to remote providers.
- 33
What is a hypervisor and what role does it play in IaaS?
Model answer
A hypervisor (or Virtual Machine Manager) runs multiple virtual machines on a single physical machine, each with its own OS. It is an OS of OSes, often Linux.
Explanation
Hypervisors enable efficient resource sharing in cloud data centers.
- 34
How has the market share of operating systems evolved recently?
Model answer
Personal devices: Windows and Android (Linux-based) dominate; macOS and iOS (Unix-based) have significant shares. Servers are dominated by Linux/Unix.
Explanation
The OS landscape has become more homogeneous, with Unix-like systems prevalent.
- 35
What is a kernel panic and what typically causes it?
Model answer
A kernel panic is a fatal error in the kernel where it cannot recover. It usually results from severe memory corruption or hardware faults, causing the system to shut down with a panic message.
Explanation
In early systems, it often led to data loss and required reboot; modern systems may have more graceful handling.
- 36
Why are Unix and Linux primarily written in C, and can they be rewritten in other languages?
Model answer
C provides efficient low-level control while being portable. Yes, kernels can be written in higher-level languages, but small critical parts often need assembly for speed.
Explanation
Performance requirements typically demand some assembly-level optimization.

Ask anything
We've read this whole study set, so questions about it get the best answers.