CSS Prepare

optional · CSS study notes

OS Structures and Operations

CSS Optional — Paper-II, Section-A · P-II.III.I (cont.) · Previously missing from this vault — added because "Structures, and Operations" is named explicitly in the syllabus line for this topic, distinct from Classification (which is about purpose, not internal architecture).

1. OS Structures (how the OS itself is internally organized)

graph TD
    S["OS Structures"] --> M["Monolithic
(all in one address space)"]
    S --> L["Layered
(strict layer-on-layer)"]
    S --> MK["Microkernel
(minimal kernel + user-space servers)"]
    S --> MOD["Modular
(loadable kernel modules)"]
    S --> H["Hybrid
(monolithic core + microkernel-style modules)"]
StructureIdeaStrengthWeaknessExample
MonolithicEntire OS (process/memory/file/device management) runs together in one large privileged programFast — direct function calls, no IPC overheadA bug/crash in any driver can crash the whole system; hard to maintainTraditional UNIX, original Linux
LayeredOS built as a stack of layers, each using only the services of the layer directly below itEasy to design, debug, and verify layer by layerStrict layering hurts performance (every call may cascade through layers); hard to define correct layer boundariesTHE (early academic OS)
MicrokernelOnly bare minimum (IPC, minimal scheduling, minimal memory management) runs in kernel mode; file systems, drivers, network stacks run as user-space "servers"Robust, secure, modular — a failing server can be restarted without crashing the kernelPerformance overhead from extra message-passing/context switchesMinix, QNX
ModularMonolithic-style kernel core, but functionality added/removed at runtime as loadable kernel modulesCombines monolithic speed with some of microkernel's flexibilityModules still typically run in the same privileged space, so a bad module can still crash the kernelModern Linux, Solaris
HybridA monolithic-like core for performance, with some services designed in a microkernel-like modular fashionPragmatic performance/robustness balanceMore complex design decisions about what goes whereWindows NT-family, macOS (XNU)

2. Dual-Mode Operation

To protect the OS and other processes from a malfunctioning or malicious program, hardware provides at least two modes, tracked by a mode bit:

  • User mode (mode bit = 1): a running application; privileged instructions (direct I/O, memory management, halting the CPU) are disallowed and trap to the OS if attempted.
  • Kernel/System/Supervisor mode (mode bit = 0): the OS itself; all instructions are permitted.

When a user program needs a privileged operation, it cannot execute it directly — it must invoke a system call, which switches the mode bit to kernel mode for the duration of that service, then switches back.

3. System Calls

A system call is the programming interface through which a user-space program requests a service from the kernel (the only sanctioned door between the two modes).

CategoryExamples
Process controlcreate/terminate process, load/execute, wait, allocate memory
File managementcreate/delete/open/close/read/write a file
Device managementrequest/release a device, read/write, attach/detach
Information maintenanceget/set time, date, system data, process/file attributes
Communicationsend/receive messages, create/delete a communication connection
Protectionget/set file permissions, allow/deny access

Mechanism: a system call is invoked (commonly via a library wrapper), which executes a special trap instruction; this switches to kernel mode and transfers control to a fixed entry point in the OS, which looks up the requested service by its system call number in a table, executes it, then returns control (and mode) back to the user process.

4. OS Operations

  • Interrupt-driven: nearly everything the OS does is triggered by an interrupt (hardware interrupt from a device, or a software "trap"/exception from a program) — the OS is fundamentally reactive, not a continuously-polling loop.
  • Multiprogramming: keeping several jobs in memory so the CPU always has something to run.
  • Multitasking/Time-sharing operation: the CPU switches so quickly between jobs that interactive users perceive simultaneous execution (see [Role and Evolution of Operating Systems] for the historical build-up to this).

5. Virtual Machines (a structure question examiners increasingly ask alongside monolithic/microkernel)

A Virtual Machine (VM) uses a software layer — the hypervisor (Virtual Machine Monitor, VMM) — to present each guest OS with what looks like its own dedicated hardware, even though several guests share one physical machine.

TypeWhere the hypervisor runsExample
Type 1 (bare-metal / native)Directly on the hardware, no host OS underneathVMware ESXi, Xen, Microsoft Hyper-V
Type 2 (hosted)As an application on top of a conventional host OSVMware Workstation, Oracle VirtualBox

Benefits: strong isolation between guests (a crash in one VM cannot affect another), the ability to run multiple different OSes simultaneously on one machine, easy snapshotting/migration — this is the foundational technology behind Cloud Computing's IaaS model (see [Computing Environments]).

Containers (a lighter-weight sibling worth contrasting in the same answer): rather than virtualizing hardware, a container virtualizes at the OS level — all containers on a host share the same kernel but have isolated filesystems/processes/network. Containers (Docker) start faster and use fewer resources than VMs, but provide weaker isolation since they share one kernel.

6. Exokernel (a structure examiners sometimes list as a sixth category)

An even more minimal design than a microkernel: the kernel allocates raw hardware resources (CPU slices, disk blocks) to library OSes running in user space, but implements almost no abstractions itself — application-level libraries decide how to use the hardware. Rarely used commercially, but sometimes appears as a "name one more OS structure" MCQ distractor.

7. Process Creation Recap (ties structure to operation)

At boot, the very first process created (init in UNIX-family systems, PID 1) is the ancestor of every other process — every subsequent process is created via a fork() (duplicate the calling process) followed by an exec() (replace the child's memory image with a new program) in UNIX-style systems, detailed further on the [Process Management] page.

🎯 CSS Exam Angle

"Kernel" questions (2020) expect a definition first, THEN the monolithic-vs-microkernel comparison table — don't skip straight to the comparison. "System mode" MCQs (2024) test whether you know that system/kernel mode literally means the CPU is currently executing OS code, not merely that a privileged program is installed. If asked to "name OS structures," listing all five/six from section 1 (not just monolithic and microkernel) plus VMs as a bonus is what earns full marks on a "discuss OS structures" essay rather than a short-note.

📄 Past CSS Paper Questions on this Topic

YearQuestionMarks
2020What is the kernel of an OS? Explain the difference between monolithic and microkernel.7
2024 MCQA computer is in System mode when: (Ans: CPU is executing a program which is part of the operating system)1
2024 MCQWhich is better, time slicing or time sharing? (Ans: Time sharing — gives multiple users the illusion of each having their own processor)1
2024 MCQWhich type of algorithms are applicable to scheduling resources in operating systems? (Ans: State space search)1
2024 MCQWhich of the following is true about OS design? (Ans: Operating systems can be made without using assembly languages)1

⚠️ MCQ Traps

  • System/kernel mode = the CPU is currently running OS code — not "a process is halted" and not "the system is switching between processes" (both were wrong distractors in the 2024 MCQ).
  • Microkernel is not automatically "better" — it trades raw speed for robustness/modularity; monolithic kernels remain dominant in production (Linux) precisely because of the performance trade-off.
  • A system call is the ONLY sanctioned way from user mode into kernel mode — a user program cannot simply execute a privileged instruction directly; doing so traps as an illegal-instruction/protection fault instead of running.
  • A container is NOT a lightweight VM in the strict sense — it shares the host kernel; a VM does not. If a question asks which gives stronger isolation, the answer is the VM.
  • "Time slicing" and "time sharing" are not interchangeable in the 2024 MCQ's framing — the official answer treats time sharing as the user-facing concept (the illusion each user has their own machine) and marks it "better," even though time slicing is the underlying mechanism that makes it possible; memorize the official answer even if the premise feels like comparing a means to its own end.
  • "State space search" as the answer for CPU scheduling algorithms is the FPSC-key answer for a 2024 MCQ, even though it doesn't match how scheduling is normally taught (as queueing/priority rules, not AI search) — flag this as an officially-keyed answer to memorize rather than a concept to reason out from first principles.
  • Modern OSes are written almost entirely in high-level languages (C/C++) with only small assembly-language stubs for the lowest-level hardware bring-up — "OS can be made without assembly" is the intended true statement, not the platform-independence or internet-dependency distractors.

📜 Past-Paper Questions & MCQs (CSS 2016–2026)

MCQs

2024 P-II · Q2. A computer is in system mode when:

  • (A) The CPU is executing a program which is part of the operating system ✅
  • (B) The process execution is halted to listen to device inputs
  • (C) The system is switching between processes
  • (D) None of these
  • Answer: (A).
  • Why: system (kernel) mode is the privileged mode in which operating-system code runs. User programs run in user mode. (B) and (C) are specific events (interrupt handling and context switching) that also happen to run OS code, but (A) is the general definition.

2024 P-II · Q7. Which is better, time slicing or time sharing?

  • (A) Time slicing is better because it deals with process allocation at the CPU level
  • (B) Time sharing is better because it gives multiple users the illusion of each having his own processor
  • (C) The comparison is not possible because one is part of the other ✅
  • (D) None of these
  • Answer: (C).
  • Why: time sharing is the goal (many users share the machine interactively), and time slicing is the technique the scheduler uses to achieve it, by giving each process a short quantum. They are not competing alternatives.

2026 P-II · Q20. Which of these is a method of file protection?

  • (A) Access Control ✅
  • (B) Deleting a file
  • (C) Hiding a file
  • (D) None of these
  • Answer: (A) Access Control.
  • Why: access control (permissions, ACLs, passwords) decides who may read, write or execute a file. Deleting destroys the file, and hiding only makes it less visible without real protection.