0% found this document useful (0 votes)
3 views26 pages

OS Unit2 Detailed Notes

The document provides comprehensive notes on operating systems, covering key topics such as operating system services, user interfaces, system calls, and their types. It categorizes services into those benefiting users and those ensuring efficient system operation, detailing functionalities like program execution, I/O operations, and resource allocation. Additionally, it discusses command interpreters, APIs, and the various methods of passing parameters to system calls, along with examples and previous year question-style prompts for exam preparation.

Uploaded by

lizzieislameee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views26 pages

OS Unit2 Detailed Notes

The document provides comprehensive notes on operating systems, covering key topics such as operating system services, user interfaces, system calls, and their types. It categorizes services into those benefiting users and those ensuring efficient system operation, detailing functionalities like program execution, I/O operations, and resource allocation. Additionally, it discusses command interpreters, APIs, and the various methods of passing parameters to system calls, along with examples and previous year question-style prompts for exam preparation.

Uploaded by

lizzieislameee
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

OPERATING SYSTEMS

Unit 2 — Complete Exam Notes

BA(CA) + Mathematics | Delhi University | STEM 4

Silberschatz — Operating System Concepts

Table of Contents

Chapter 2.1 Operating System Services


Chapter 2.2 User Interface and Command Interpreters
Chapter 2.3 System Calls
Chapter 2.4 Types of System Calls
Chapter 2.5 System Programs
Chapter 2.7 Operating System Structure
Chapter — Key Definitions to Memorise
CHAPTER 2.1

Operating System Services

Overview

An operating system provides an environment in which programs can be executed. In order to fulfil
this role, it offers a defined set of services — both to the user who interacts with the system and to
the system itself so that it can operate efficiently. These services can be divided into two broad
categories: those that benefit the user, and those that benefit the system.

Category Purpose Services Included

For the User Make the system convenient and UI, Program Execution, I/O Operations, File System
usable Manipulation, Communication, Error Detection

For the System Ensure efficient and secure Resource Allocation, Accounting, Protection and
operation Security

Category A — Services Provided to the User

1. User Interface (UI)


The user interface is the means through which a user communicates with the operating system. Every
operating system must provide at least one form of user interface. There are three principal types:

Type Full Form How It Works

CLI Command Line Interface The user types text-based commands directly using the keyboard. The
shell reads each command and executes it.

GUI Graphical User Interface The user interacts through windows, icons, menus, and a pointing
device (mouse/touchpad). Examples: Windows, macOS.

Batch Batch Interface Commands are written into a file in advance. The entire file is
submitted to the system and executed as a batch, without user
interaction during execution.

2. Program Execution
The operating system is responsible for loading a program from secondary storage into main memory and
executing it. Once the program finishes its task, the OS must be able to end it, either normally (when the
program completes successfully) or abnormally (when an error occurs that prevents normal completion).
The OS handles both scenarios and reports appropriate status information to the user.
3. I/O Operations
While a program is running, it may need to perform input or output operations — for example, reading data
from a file or sending output to a printer. A running program is not permitted to directly access I/O devices,
because doing so without control could lead to errors or data corruption. The operating system therefore
acts as an intermediary: it provides a safe, controlled mechanism through which programs can request I/O
operations. This protects both the device and the data.

4. File System Manipulation


Programs frequently need to work with files and directories. The operating system provides services to
create, read, write, and delete files and directories. It also manages permissions, which determine which
users or processes are allowed to access a particular file and in what manner (read, write, or execute).
Many operating systems provide support for several different types of file systems to accommodate
different storage needs.

5. Communication
There are situations where one process needs to exchange information with another process — either on
the same computer or on a different computer connected through a network. The operating system
facilitates this through two primary models:

Method How It Works Key Characteristic

Shared Memory Two or more processes are permitted to Fast — operates at memory speed. Both
access a common region of memory. They processes must agree to share and must
read and write to this shared space to coordinate their access carefully.
exchange information.

Message The operating system transfers packets of Slower but safer and easier to use,
Passing information (messages) from one process to especially across different machines.
another. Processes do not share any memory
directly.

6. Error Detection
The operating system must constantly monitor the system for errors and respond appropriately. Errors can
arise from multiple sources:
• Hardware errors: Memory faults, power failures, or failures in the CPU itself.
• I/O device errors: A parity error on a disk, a printer that has run out of paper, or a network
connection failure.
• Program errors: Division by zero, an attempt to access a memory location that the program is not
permitted to use, or excessive consumption of CPU time.
When an error is detected, the OS responds in one of three ways: it may halt the entire system (for critical
hardware errors), terminate only the offending process, or return an error code to the program so that it
can handle the problem itself.
Category B — Services Provided for Efficient System Operation

7. Resource Allocation
When several users or processes are running simultaneously, the OS must allocate the available
resources — CPU time, main memory, storage, and peripheral devices such as printers — to each of them
in a fair and efficient manner. For the CPU, the OS uses scheduling algorithms that consider factors such
as processor speed, the number of available registers, and the number of processes waiting to run.

8. Accounting
The OS keeps a record of which users use which resources, and for how long. This information serves two
purposes: it can be used for billing users in commercial systems, and it provides usage statistics that
administrators and researchers can use to reconfigure the system for improved performance.

9. Protection and Security


In a multiprogramming environment with multiple users, it is essential to ensure that processes and users
cannot interfere with one another or with the OS itself. Two related but distinct concepts apply here:

Concept Definition Threat Type

Protection Ensures that all access to system resources — CPU, Internal (between processes on
memory, files, devices — is controlled and authorised. the same system)
Prevents one process from accessing another's
resources.

Security Defends the system against unauthorised external External (hackers, unauthorised
access. This begins with user authentication (passwords, users)
biometrics) and includes monitoring all connections to
the system to detect and record intrusion attempts.

EXAM LINE: "A chain is only as strong as its weakest link." — This is the standard justification for why all
components of a system must be protected, not just some of them.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ List and explain the services provided by an OS to users. (10 marks)

→ Differentiate between protection and security in an OS. (3 marks)

→ What is the role of error detection in an OS? Give examples of different types of errors. (5 marks)

→ Explain shared memory and message passing as methods of communication between processes. (5
marks)

MEMORY TRICK: "UI-PIFCE" — UI, Program execution, I/O, File system, Communication, Error detection
(the 6 user services) | "RAP" — Resource allocation, Accounting, Protection & Security (the 3 system
services)
CHAPTER 2.2

User Interface and Command Interpreters

What Is a Shell?

A shell, also called a command interpreter, is a special system program whose primary function is to
receive commands from the user and cause the operating system to execute them. It acts as the
interface between the human user and the operating system kernel. The shell does not itself carry
out the operations — it passes the instructions to the OS and displays the results.

In some operating systems, the command interpreter is part of the kernel itself. In others — such as
Windows and UNIX/Linux — it runs as a separate program that is launched when the user logs in.
Systems that provide multiple command interpreters refer to each one as a shell.

Shells Available in UNIX/Linux

Shell Name Notes

Bourne Shell The original shell of UNIX. All other shells are, in some way, derived from or
compared to it.

C Shell Uses a syntax similar to the C programming language, making it familiar to C


programmers.

Bourne-Again Shell (bash) The most widely used shell today. It is the default shell in most Linux
distributions.

Korn Shell Combines the best features of the Bourne shell and the C shell.

Two Approaches to Implementing Commands


There are two different approaches that an OS can take when deciding how a command interpreter
actually executes commands:

Approach How It Works Used By Drawback

Code inside the The shell itself contains the code to MS-DOS As more commands are
interpreter execute each command. When a added, the shell grows larger.
command is typed, the shell runs the It becomes difficult to
corresponding code from within itself. maintain and update.
Approach How It Works Used By Drawback

System programs The shell does not understand commands UNIX/Linux None — this approach is
(external files) at all. It simply uses the command name to highly flexible and easy to
find a separate file (program) with that extend.
name, loads it into memory, and executes
it.

The UNIX Approach — An Illustration


When a user types the command rm [Link] in a UNIX shell, the following sequence of events occurs:
• The shell does not know what 'rm' means internally.
• It searches for a file named 'rm' in the directories listed in the system's path.
• Once found, it loads that program into memory.
• It passes '[Link]' as an argument (input) to that program.
• The 'rm' program executes and deletes the file.
The key advantage of this approach is that new commands can be added to the system simply by creating
new program files. There is no need to modify or recompile the shell itself. This makes the system
extremely flexible and easy to extend.

IMPORTANT: User interface design is NOT considered a direct function of the operating system. It
belongs to the system programs layer, not the kernel.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What is a command interpreter? Explain the two approaches to implement commands in a CLI. (5
marks)

→ What is a shell? Name any four shells available in UNIX/Linux. (3 marks)

→ How does UNIX implement the 'rm' command? Which approach does it use? (3 marks)

MEMORY TRICK: "Shell = Translator" — it translates human commands into operating system actions.
CHAPTER 2.3

System Calls

Definition and Purpose

A system call is the mechanism through which a user-level program requests a service from the
operating system. It provides a programmatic interface between a running program and the services
made available by the OS kernel. System calls are the only legitimate way for a program to cross
from user mode into kernel mode.

Every program runs in user mode — a restricted mode of operation in which the program cannot directly
access hardware, memory of other processes, or critical OS data structures. When a program needs to
perform a privileged operation — such as reading a file, allocating memory, or communicating over a
network — it must make a system call. The CPU then switches to kernel mode, the OS performs the
requested service, and control is returned to the program.
System calls are primarily written in C or C++. For very low-level hardware tasks, assembly language is
used.

Example — System Calls in a File Copy Program


Even a seemingly simple task like copying one file to another involves a large number of system calls. The
table below traces the sequence:

Ste Action Type of System Call


p

1 Display a prompt asking for the input file name Write to screen

2 Read the input file name entered by the user Read input

3 Display a prompt asking for the output file name Write to screen

4 Read the output file name entered by the user Read input

5 Open the input file; if not found, print error and File open / error handling / abort
abort

6 Create the output file; if it already exists, ask user File create / read input
to overwrite or abort

7 Loop: read a block from the input file, write it to File read / file write (repeated)
the output file

8 Close both files after the copy is complete File close


Ste Action Type of System Call
p

9 Display a success message Write to screen

10 Terminate the program normally Process terminate

NOTE: Even a simple program can make thousands of system calls per second. This illustrates how
fundamental system calls are to the operation of any program.

Application Programming Interface (API)

An Application Programming Interface (API) is a set of functions made available to the programmer
that specify: what parameters each function accepts, what operations it performs, and what values it
returns. Internally, these API functions make the actual system calls on behalf of the programmer.

Programmers almost always use APIs rather than making system calls directly. There are two primary
reasons for this:
• Portability: Code written using a standard API (such as POSIX) will run on any system that supports
that API, without modification.
• Simplicity: System calls are complex, require precise parameter values, and differ between
operating systems. APIs hide this complexity behind simple, well-documented function calls.

API Used For Library (C)

Windows API All programs running on Microsoft Windows systems —

POSIX API Programs on UNIX, Linux, and Mac OS X libc

Java API Programs running on the Java Virtual Machine —

Example: When a programmer calls printf() in C, the C standard library internally calls the write() system
call, which causes the OS to send output to the screen. The programmer never interacts with the system
call directly.

Passing Parameters to System Calls


When a system call is made, the OS often needs additional information — for example, the name of a file
to open or the address of a memory block. These additional pieces of information are called parameters.
There are three methods for passing parameters to the OS:
Method How It Works Used By Limitation

Registers The parameters are placed directly into Basic systems The number of parameters is
the CPU's registers before the system limited by the number of CPU
call is made. The OS reads them from registers available.
there.

Block / Table The parameters are stored in a Linux, Solaris None — there is no limit on
contiguous block (table) in memory. the number or size of
The address of that block is placed in a parameters.
register. The OS reads the address and
retrieves the parameters from memory.

Stack The program pushes the parameters Some operating None — there is no limit on
onto the process stack before making systems the number or size of
the system call. The OS pops them off parameters.
the stack to retrieve them.

KEY POINT: The Block and Stack methods are preferred over Registers because they do not impose any
limit on the number or length of parameters that can be passed.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What is a system call? Why do programmers use APIs instead of direct system calls? (5 marks)

→ Explain the three methods of passing parameters to the OS during a system call. (5 marks)

→ With the help of an example, explain how system calls are used in a simple file copy program. (10
marks)

→ What is an API? Name the three most common APIs used in programming. (3 marks)

MEMORY TRICK: "Menu = API, Kitchen = System Call" — The API is the menu you order from; the
system call is the actual cooking that happens behind the scenes. | "RBS" — Registers, Block/Table, Stack
(3 parameter passing methods)
CHAPTER 2.4

Types of System Calls

Overview — Six Categories


System calls are grouped into six broad categories based on the type of service they provide:

# Category What It Handles

1 Process Control Creating, running, stopping, and managing processes

2 File Management Creating, opening, reading, writing, and deleting files

3 Device Management Requesting, using, and releasing hardware devices

4 Information Maintenance Getting and setting system information, time, and date

5 Communication Enabling processes to exchange information with each other

6 Protection Controlling who can access what resources in the system

Type 1 — Process Control


Process control system calls are used to manage the lifecycle of processes — from creation to termination
— as well as to control how processes interact with each other and with shared resources.

System Call What It Does

end() / abort() Stop a program. end() indicates normal completion; abort() indicates an
error has caused abnormal termination.

load() / execute() Load another program into memory and begin its execution.

create_process() / Create a new process (child process) or forcibly terminate an existing


terminate_process() one.

get_process_attributes() / Read or modify the properties of a process, such as its priority or


set_process_attributes() maximum allowed CPU time.

wait_time() / wait_event() / Cause a process to pause for a specified amount of time, or wait until a
signal_event() particular event occurs. Another process can signal that the event has
happened.

acquire_lock() / release_lock() Lock a shared resource so that only one process can use it at a time,
preventing simultaneous conflicting writes.
MS-DOS vs FreeBSD — A Comparison
These two systems illustrate contrasting approaches to process management:

Feature MS-DOS (Single-tasking) FreeBSD (Multitasking)

Concurrency Only one process can run at a Multiple processes can run simultaneously.
time.

Creating a new process No new process is created. The Uses fork() to create a new child process that
shell overwrites itself to give is a copy of the parent.
maximum memory to the
program.

Loading a program The shell is overwritten in Uses exec() to replace the child process's
memory by the new program. memory with a new program.

While program runs The shell is gone — it no longer The shell remains running in the background.
exists in memory.

When program ends MS-DOS reloads its shell from The child process calls exit(), returning a
disk. status code to the parent.

Background processes Not possible. Possible, though such processes cannot


directly interact with the keyboard.

KEY CALLS IN FreeBSD: fork() — creates a new process (a copy of the calling process). exec() —
replaces the calling process's program with a new program. exit() — terminates the process and returns a
status code (0 = success, non-zero = error).

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ Explain process control system calls with examples. (5 marks)

→ Differentiate between MS-DOS and FreeBSD in terms of process control. (5 marks)

→ What is fork()? What is exec()? How are they used in FreeBSD? (5 marks)

Type 2 — File Management


File management system calls provide all the operations a program needs to work with files stored on disk.
The same types of operations also apply to directories.

System Call What It Does

create() / delete() Create a new file or remove an existing one from the file system.

open() / close() Open a file before reading or writing to it, establishing a connection between
the program and the file. Close it when operations are complete.
System Call What It Does

read() / write() Read data from a file into the program, or write data from the program into
the file.

reposition() Move the file pointer to a different location within the file, allowing
non-sequential access.

get_file_attributes() / Read or modify a file's attributes, such as its name, type, protection codes,
set_file_attributes() and size.

Operation Windows System Call UNIX System Call

Create a file CreateFile() open()

Read from a file ReadFile() read()

Write to a file WriteFile() write()

Close a file CloseHandle() close()

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ List and explain the file management system calls provided by an OS. (5 marks)

Type 3 — Device Management


A running program often requires access to physical devices — disk drives, printers, display screens, and
so on. Device management system calls allow programs to request, use, and release these devices in a
controlled manner.

System Call What It Does

request() / release() Request exclusive access to a device before using it. Release the device
when done so that other processes can use it.

read() / write() / reposition() Perform the same read, write, and seek operations on devices that are
performed on files.

get_device_attributes() / Read or modify the settings of a device, such as the baud rate of a serial
set_device_attributes() port.

attach / detach devices Logically connect a device to the system (mount) or disconnect it (unmount).

IMPORTANT — UNIX Similarity: In UNIX, devices and files are treated almost identically. The same
system calls — read(), write() — work on both files and devices. This design simplifies programming and
creates a uniform interface for all I/O.
WARNING: If devices are not properly managed, two processes may simultaneously attempt to use the
same device, leading to a deadlock — a situation where neither process can proceed. (Deadlocks are
covered in detail in Chapter 7.)

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ Explain device management system calls. How are devices similar to files in UNIX? (5 marks)

Type 4 — Information Maintenance


Information maintenance system calls are used to transfer information between the running program and
the operating system. They allow programs to query or modify the current state of the system.

System Call / Feature What It Does

time() / date() Retrieve the current date and time from the system clock.

get_system_data() Retrieve system-level information such as the number of logged-in users, the
OS version, the amount of free memory, and the amount of free disk space.

dump() Write the current contents of memory to disk. This is used for debugging —
when a program crashes, the memory dump is saved and later examined by
a debugger.

get/set_process_attributes() Read or modify the attributes of a running process (e.g., its priority, status, or
time limits).

Single-step mode A debugging feature in which the CPU executes exactly one instruction, then
generates a trap (interrupt) so the debugger can inspect the system state
before the next instruction runs.

Time profile Uses timer interrupts to record how much CPU time the program spends at
each point in its code. This helps identify performance bottlenecks.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What are information maintenance system calls? Give examples. (3 marks)

Type 5 — Communication
Communication system calls allow processes to exchange information with one another. There are two
models:

Model 1 — Message Passing


In the message passing model, processes communicate by explicitly sending and receiving messages.
The OS acts as the carrier — it transfers the message from the sender to the receiver. The following steps
are involved:
• A connection must be established before communication begins. Each machine has a host name and
an IP address; each process has a process name or ID, which is obtained via get_hostid() and
get_processid().
• The receiving process (typically a daemon — a background process) calls wait_for_connection() and
listens for incoming messages.
• The sender (client) and receiver (server) exchange data using read_message() and write_message().
• When communication is complete, close_connection() terminates the connection.

Model 2 — Shared Memory


In the shared memory model, two or more processes communicate by reading from and writing to a
common region of memory. The following steps are involved:
• shared_memory_create() — one process creates a shared memory region.
• shared_memory_attach() — other processes connect (attach) to that region.
• Normally, the OS prevents one process from accessing another process's memory. For shared
memory to work, both processes must explicitly agree to remove this restriction.
• The OS does not control the format or content of the data being exchanged. The processes
themselves are responsible for organising the data and ensuring they do not write to the same location
at the same time.

Feature Message Passing Shared Memory

Speed Slower — data is copied by the OS from Faster — data is accessed directly
one process to another. in memory.

Best For Smaller amounts of data. Larger amounts of data.

Ease of Use Easier to implement, especially across Harder — requires careful


different machines. synchronisation.

OS Involvement OS manages the transfer of messages. OS creates the shared region;


processes manage all data access.

Typical Use Case Communication between processes on Communication between processes


different computers. on the same computer.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ Explain the two models of communication used in OS. Compare message passing and shared memory.
(10 marks)

→ What is a daemon? What role does it play in message passing communication? (3 marks)

Type 6 — Protection
Protection system calls are used to control access to the resources of the system. They allow
administrators and programs to specify who can access what, and under what conditions.
System Call What It Does

set_permission() / get_permission() Set or retrieve the access permissions on files, directories, or disks (e.g.,
read-only, read-write, execute).

allow_user() / deny_user() Explicitly allow or block a specific user from accessing a specific
resource.

In the early days of computing, protection was only a concern for large multi-user systems. Today, with the
widespread use of networking and the internet, even single-user devices such as mobile phones require
robust protection mechanisms.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What are protection system calls? List any four examples. (3 marks)

→ List all six types of system calls and give two examples of each. (10 marks)

MEMORY TRICK: "PF-DIC-P" — Process control, File management, Device management, Information
maintenance, Communication, Protection | "fork = photocopy yourself, exec = become someone else" |
"WhatsApp = Message Passing, Google Docs = Shared Memory"
CHAPTER 2.5

System Programs

Definition and Position in the System

System programs, also called system utilities, are a collection of programs that provide a convenient
environment for program development and execution. They sit as a layer between the operating
system kernel and the application programs that users install. Most users interact with system
programs far more than with the OS kernel itself — in fact, what many users think of as 'the operating
system' is largely the collection of system programs that come pre-installed with the OS.

Layer Examples

Application Programs (top) Web browsers, word processors, games — installed by the user

System Programs File manager, text editor, compiler, Task Manager — come with the OS

Operating System Kernel Process scheduling, memory management, device drivers

Hardware (bottom) CPU, RAM, disk, I/O devices

The Seven Categories of System Programs

1. File Management
These programs create, delete, copy, rename, print, list, and otherwise manage files and directories. They
provide a user-friendly way to perform the same operations that file management system calls perform at
the program level.
Examples: File Explorer (Windows), and commands such as ls, cp, mv, rm in Linux.

2. Status Information
These programs query the system for current status information and display it to the user. The types of
information they can provide include:
• Current date and time
• Amount of available memory and disk space
• Number of users currently logged in
• Performance metrics, error logs, and debugging data
Some operating systems store configuration information in a centralised database called the registry.
Status programs can read from and write to the registry to retrieve or update configuration settings.
Example: Task Manager (Windows), top / htop (Linux).
3. File Modification
These programs allow users to create and modify files stored on disk. They include text editors as well as
specialised tools for searching within files or performing transformations on file content.
Examples: Notepad (Windows), Vim, Nano, and Gedit (Linux).

4. Programming Language Support


The OS typically provides or includes tools to support the development of programs. These tools transform
source code written by a programmer into a form the machine can execute:

Tool What It Does Example

Compiler Translates the entire source code of a program into GCC (for C/C++)
machine language in one step.

Assembler Translates assembly language (low-level symbolic code) NASM


into machine code.

Debugger Allows the programmer to run a program step by step GDB


and examine its state to identify and fix errors.

Interpreter Executes source code line by line at runtime, without Python interpreter
compiling it first.

5. Program Loading and Execution


After a program has been compiled, it must be loaded into main memory before it can run. These
programs facilitate this process:

Tool What It Does

Absolute loader Loads the program at a fixed, pre-determined memory address.

Relocatable loader Loads the program at any available memory location, adjusting addresses as
needed.

Linkage editor Combines multiple separately compiled program files (object files) into a single
executable.

Overlay loader Loads only the currently needed part of a very large program into memory,
swapping parts in and out as required.

Debugger Used after loading to trace and fix errors in the program during execution.

6. Communications
These programs provide the mechanisms for users and processes to communicate with each other, both
on the same machine and across a network. They include programs that allow users to:
• Send messages to the screens of other users on the same system
• Browse web pages through a web browser
• Send and receive electronic mail
• Log into a remote computer and execute commands on it
• Transfer files between two different machines

7. Background Services (Daemons)

A daemon is a system program process that starts automatically at boot time and continues running
in the background until the system is shut down. Daemons are never directly visible to the user but
provide essential services to the OS and other programs.

Examples of common daemons:

Daemon What It Does

Network daemon Listens continuously for incoming network connection requests and handles
them.

Process scheduler daemon Starts processes or jobs at pre-scheduled times (e.g., nightly backups).

Error monitoring daemon Continuously watches for system errors and logs them or alerts administrators.

Print server daemon Manages the queue of print jobs and sends them to the printer in order.

Some daemons complete a specific task and then stop. Others run indefinitely until the system is shut
down. A typical operating system has dozens of daemons running at any given time.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What are system programs? List and explain their categories with examples. (10 marks)

→ What is a daemon? Give three examples of daemons. (3 marks)

→ Differentiate between system programs and application programs. (3 marks)

→ What is a registry? What is it used for? (3 marks)

MEMORY TRICK: "FS-FP-LCB" — File management, Status information, File modification, Programming
language support, Loading and execution, Communications, Background services
CHAPTER 2.7

Operating System Structure

Introduction
A modern operating system is an extremely large and complex piece of software. It must be designed with
care so that it functions correctly, can be maintained over time, and can be modified or extended without
breaking existing functionality. The fundamental principle is to divide the OS into smaller, manageable
components. There are four principal approaches to structuring an OS:

Structure 1 — Simple / Monolithic Structure

In a simple or monolithic structure, the OS is not divided into clean, separate modules. All
components of the kernel — memory management, file system, device drivers, CPU scheduling —
are combined into a single large program running in kernel mode. Different parts of the kernel can
call any other part directly, without restriction.

MS-DOS as an Example
MS-DOS was written by a small team with the goal of providing maximum functionality in minimum
memory space. Because it was never expected to become widely used, it was not designed with a clean
modular structure. The consequences were significant:
• The system was not divided into proper modules — all layers of the OS could communicate with all
other layers directly.
• Application programs could directly access hardware — the display adapter, disk controller — without
going through the OS.
• This made the system highly vulnerable: a single poorly written or malicious program could corrupt
the entire system or cause it to crash.
• The Intel 8088 processor on which MS-DOS ran had no dual-mode operation (no user mode / kernel
mode distinction), so hardware-level protection was not even possible.

Traditional UNIX as an Example


The original UNIX kernel is also monolithic but has a slightly more organised structure. It consists of two
parts: the kernel and the system programs. The kernel contains everything between the system-call
interface and the hardware: the file system, CPU scheduler, memory manager, and all device drivers — all
in one large layer.

Aspect Detail

Advantage Very fast execution, because all kernel components can communicate directly with no
overhead from passing messages or switching layers.
Aspect Detail

Disadvantage The kernel is enormous, extremely difficult to implement, and very hard to maintain or
modify.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What is a simple/monolithic OS structure? Explain with MS-DOS as an example. (5 marks)

→ Draw and explain the traditional UNIX system structure. (5 marks)

→ Why was MS-DOS vulnerable to malicious programs? (3 marks)

Structure 2 — Layered Approach

In the layered approach, the operating system is organised as a hierarchy of layers. The bottommost
layer (Layer 0) is the hardware. The topmost layer (Layer N) is the user interface. Each layer is built
on top of the layer below it, and may only use the services provided by the layers directly beneath it.
No layer may call a layer above it.

Layer Component

Layer N (Top) User Interface

… Higher-level OS services

Layer 2 Memory Management

Layer 1 CPU Scheduling

Layer 0 (Bottom) Hardware

Advantages
• Simple construction: Each layer is built and tested in isolation, using only the verified lower layers.
• Easy to debug: Debugging proceeds from the bottom up. If a bug is found in Layer 3, the
programmer already knows that Layers 0, 1, and 2 are correct. This greatly narrows the search for the
cause.
• Information hiding: Each layer only needs to know what the layers below it provide — not how they
provide it. Implementation details are hidden.

Disadvantages
• Difficult to define layers correctly: Deciding which component belongs in which layer requires
careful planning. For example: the disk driver must be below the memory manager (because the
memory manager may need to use the disk). But the CPU scheduler may need to be above the disk
driver (because scheduling may depend on disk activity). Working out the correct ordering for all
components is complex.
• Less efficient: A system call must pass through every layer between the user and the hardware.
Each layer adds a small amount of time overhead. In a system with many layers, this cumulative
overhead significantly reduces performance.
• Modern systems use fewer layers with more functionality in each to reduce this overhead.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ Explain the layered approach of OS structure. What are its advantages and disadvantages? (10 marks)

→ Why is the layered approach less efficient than a monolithic structure? (3 marks)

Structure 3 — Microkernel

The microkernel approach structures the OS by removing all non-essential components from the
kernel and implementing them as user-level programs in user space. The result is a very small kernel
that contains only the absolute minimum required for the system to function.

HISTORICAL NOTE: The microkernel approach was developed in the mid-1980s at Carnegie Mellon
University. The operating system produced was called Mach.

What Remains Inside the Microkernel?


• Basic process management (creating and scheduling processes)
• Basic memory management (allocating and protecting memory regions)
• Communication facility (the message passing mechanism)
Everything else — including the file system, device drivers, and network protocols — is moved out of the
kernel and runs as a user-level program (a server process) in user space.

How Communication Works


When a client program needs a service (e.g., reading a file), it does not contact the file system server
directly. All communication between clients and servers must pass through the microkernel via message
passing. The microkernel acts as the intermediary — it receives the request, routes the message to the
appropriate server, and returns the result to the client.

Advantages
• Easy to extend: New services can be added by creating new user-space server processes. The
kernel itself does not need to be modified or recompiled.
• Easy to port: Because the kernel is small, it is much easier to adapt it to run on a new hardware
architecture.
• More reliable and secure: If a server process (e.g., the file system server) crashes, only that service
is affected. The kernel itself continues to run. In a monolithic kernel, a crash in any driver or module
can bring down the entire system.
• Smaller kernel = fewer bugs: A smaller codebase is easier to verify, test, and maintain.
Disadvantages
• Performance overhead: All communication between components must go through the microkernel's
message passing mechanism. This involves two context switches and two memory copies for every
interaction, which is significantly more expensive than a direct function call within a monolithic kernel.
• Real-world example: Windows NT was originally designed as a microkernel OS. Its performance
was so poor that many services had to be moved back into the kernel. Windows XP and later versions
are therefore more monolithic than the original NT design.

Operating System Notes

Mach The original microkernel, developed at Carnegie Mellon University.

Mac OS X (Darwin) The core of macOS is partly based on the Mach microkernel.

Tru64 UNIX A UNIX-compatible OS built on top of a Mach kernel.

QNX A real-time OS widely used in embedded and safety-critical systems. Its microkernel
handles only message passing, process scheduling, and hardware interrupts.

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What is a microkernel? Explain its structure, advantages and disadvantages with examples. (10 marks)

→ Compare monolithic kernel with microkernel. (5 marks)

→ Who developed the microkernel approach? Name the OS. (2 marks)

Structure 4 — Modules (Loadable Kernel Modules)

The modular approach organises the kernel around a small set of core components, with additional
functionality implemented as separate modules that can be loaded into the kernel either at boot time
or dynamically during runtime. This is the approach used by most modern operating systems,
including Linux, Solaris, and Mac OS X.

Key Characteristics
• The kernel provides essential services: CPU scheduling, basic memory management.
• Any additional service — a new file system, a new device driver, a new network protocol — can be
implemented as a module and loaded when needed.
• Modules can be loaded at boot time (before the OS is fully running) or at runtime (while the system is
already in use), without rebooting the system.
• No need to recompile the kernel to add new functionality.

Why It Is Better Than the Layered Approach


In the layered approach, each layer can only communicate with the layer immediately below it. In the
modular approach, any module can call any other module directly. This provides much greater flexibility.
Why It Is Better Than the Microkernel Approach
In the microkernel approach, all communication between components must pass through the microkernel
via message passing, which is slow. In the modular approach, modules communicate directly by calling
each other's functions, with no message passing overhead.

Solaris — Loadable Module Types

# Module Type Purpose

1 Scheduling classes Add new CPU scheduling algorithms

2 File systems Support additional file system formats

3 Loadable system calls Add new system calls without recompiling the kernel

4 Executable formats Support new binary/executable file formats

5 STREAMS modules Add components to the data stream I/O framework

6 Miscellaneous Any other kernel extension

7 Device and bus drivers Support new hardware devices and buses

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ What are loadable kernel modules? How do they differ from the layered and microkernel approaches?
(5 marks)

→ Explain the modular structure of the Solaris OS. (5 marks)

Quick Comparison — All Four OS Structures

Feature Simple/Monolithic Layered Microkernel Modules

Organisation No structure; all in Strict hierarchy of Tiny kernel + Core kernel + plug-in
one layers user-space servers modules

Speed Fast — direct calls Slow — overhead Slow — message Fast — direct module
at each layer passing calls

Easy to Maintain? No Yes Yes Yes

Easy to Extend? No Somewhat Yes — add a Yes — add a module


user-space server

Security / Reliability Low Medium High — a crashed Medium-High


server does not affect
kernel
Feature Simple/Monolithic Layered Microkernel Modules

Examples MS-DOS, original Theoretical Mach, QNX, Mac OS X Linux, Solaris,


UNIX Windows

PREVIOUS YEAR QUESTION-STYLE QUESTIONS

→ Compare and contrast the four OS structures: simple, layered, microkernel and modular. (10 marks)

MEMORY TRICK: "SLMM" — Simple, Layered, Microkernel, Modules | "Monolithic = Messy room (no
organisation) | Layered = Relay race (strict order) | Microkernel = Minimalist apartment (bare essentials
only) | Modules = Smartphone + apps (core + add what you need)"
KEY DEFINITIONS

Write these word-for-word in your exam

System calls

System calls provide an interface to the services made available by an operating system.

API

An API (Application Programming Interface) specifies a set of functions available to an application


programmer, including the parameters passed to each function and the return values the programmer
can expect.

Security

A chain is only as strong as its weakest link. — The standard argument for why every component of a
system must be secured.

Protection

Protection involves ensuring that all access to system resources is controlled.

User Authentication

Security of the system from outsiders starts with requiring each user to authenticate himself or herself
to the system, usually by means of a password.

Shell / Command Interpreter

The main function of the command interpreter is to get and execute the next user-specified command.

UNIX Command Execution

In UNIX, the command interpreter does not understand the command in any way; it merely uses the
command to identify a file to be loaded into memory and executed.

Message Passing

Message passing is useful for exchanging smaller amounts of data, because no conflicts need be
avoided.

Shared Memory
Shared memory allows maximum speed and convenience of communication, since it can be done at
memory transfer speeds.

System Programs

System programs provide a convenient environment for program development and execution.

Daemon

A daemon is a constantly running system-program process.

Microkernel

The microkernel approach structures the OS by removing all non-essential components from the
kernel and implementing them as system and user-level programs.

Layered Approach

The main advantage of the layered approach is simplicity of construction and debugging.

Loadable Kernel Modules

The kernel has a set of core components and links in additional services via modules, either at boot
time or during run time.

Best of luck for your exams. You have covered everything in this unit.

You might also like