1.
Operating System
Services…………………………………………………………………………………………….2
2. User Operating System Interface....................................................................3
3. System Calls........................................................................................................ 4
4. System Programs............................................................................................... 6
5. Operating System Structures...........................................................................6
6. Virtual Machines................................................................................................. 9
REVIEW................................................................................................................... 10
1. What criteria are OS designers interested in when designing and implementing
an OS?................................................................................................................... 10
2. What is the Java Virtual Machine (JVM)? Why do we install JVM packages for
each real machine type?....................................................................................... 10
QUESTIONS AND ANSWERS................................................................................. 10
2.4. What are the three major activities of an operating system with regard to
secondary-storage management?.........................................................................10
2.5. What is the purpose of the command interpreter? Why is it usually separate
from the kernel?.................................................................................................... 11
2.6. What system calls have to be executed by a command interpreter or shell in
order to start a new process?................................................................................11
2.8. What is the main advantage of the layered approach to system design? What
are the disadvantages of the layered approach?..................................................11
2.9. List five services provided by an operating system, and explain how each
creates convenience for users. In which cases would it be impossible for user-
level programs to provide these services? Explain your answer...........................11
2.10. Why do some systems store the OS in firmware, while others store it on
disk?...................................................................................................................... 12
2.11. How could a system be designed to allow a choice of operating systems
from which to boot? What would the bootstrap program need to do?..................12
2.16. What are the advantages and disadvantages of using the same system-call
interface for manipulating both files and devices?...............................................12
2.17. Would it be possible for the user to develop a new command interpreter
using the system-call interface provided by the operating system?.....................12
2.18. What are the two models of interprocess communication? What are the
strengths and weaknesses of the two approaches?..............................................12
2.20. It is sometimes difficult to achieve a layered approach if two components of
the operating system are dependent on each other. Identify a scenario in which it
is unclear how to layer two system components that require tight coupling of their
functionalities....................................................................................................... 12
2.21. What is the main advantage of the microkernel approach to system design?
How do user programs and system services interact in a microkernel architecture?
What are the disadvantages of using the microkernel approach?.........................13
1
2.22. What are the advantages of using loadable kernel modules?......................13
2.23. How are iOS and Android similar? How are they different?..........................13
CHAPTER 2: OPERATING-SYSTEM
STRUCTURES
1. Operating System Services
Operating systems (OS) provide an environment for running programs
and services that help both users and programs work effectively.
Services That Help Users
These are the OS features that make the computer easier to use:
1. User Interface (UI)
o Let users interact with the computer.
o Can be:
Command-Line Interface (CLI) → type commands
Graphical User Interface (GUI) → use windows, icons,
mouse
Batch Interface → submit a list of commands to run
automatically
2. Program Execution
o The OS can load, run, and end programs.
o If a program crashes or finishes, the OS handles it properly.
3. I/O Operations
o Programs often need to read or write data from devices.
o The OS manages these input/output operations.
4. File-System Manipulation
o The OS allows them to:
Create, read, write, or delete files and directories
Search for files
Manage permissions
5. Communications
o Programs or processes may need to exchange information,
either:
Within the same computer (via shared memory)
Or between different computers (via message passing
over a network)
6. Error Detection
o The OS constantly checks for errors in hardware and software.
o It takes proper action to fix problems and keep the system
stable.
o Debugging tools help users and programmers find and fix
issues.
Services That Help the System Run Efficiently
2
1. Resource Allocation
o When multiple programs or users run at once, the OS must
divide resources fairly and efficiently.
2. Accounting
o The OS tracks how much and what kinds of resources each
user or process uses.
3. Protection and Security
o Protection: Ensures one process can’t interfere with another.
o Security: Prevents unauthorized access from outsiders.
Requires user authentication (like passwords).
Protects both internal and external devices from misuse.
2. User Operating System Interface
The User Interface (UI) is how users interact with the operating
system.
There are mainly two types: Command Line Interface (CLI) and
Graphical User Interface (GUI).
Command Line Interface (CLI)
Also called a command interpreter or shell.
Users type commands directly to perform actions (e.g., copy
files, run programs).
Can be built into the kernel or provided by a system program.
Some systems have multiple types of shells (like Bash,
PowerShell, etc.).
The CLI:
o Reads a command from the user.
o Executes it
3
If commands are external programs, new features can be added without
changing the shell itself.
Graphical User Interface (GUI)
Designed to be user-friendly and visual.
Users interact using a mouse, keyboard, and monitor.
Uses icons to represent files, folders, programs, and actions.
Clicking or right-clicking icons allows users to:
o Open folders
o Run applications
o View options or information
3. System Calls
A system call is the programming interface between a user program
and the operating system (OS).
In other words, it’s how a program asks the OS to perform a service,
like reading a file or creating a process.
System calls are usually written in high-level languages (like C or C+
+).
Accessing System Calls
Programs don’t usually use system calls directly.
Instead, they use an Application Programming Interface (API), which
is easier and more portable.
Why use APIs instead of system calls directly?
The API makes programming simpler and consistent across different
systems.
The OS may change how system calls work internally, but as long as
the API stays the same, programs don’t need to change.
This provides portability — the same code can run on different
operating systems with minimal changes.
System Call Implementation
Each system call has a unique number (ID).
The system call interface in the OS maintains a table that maps
these numbers to the correct system functions.
When a program makes a system call:
1. It uses the API to request a service.
2. The system call interface passes the request to the kernel.
3. The kernel performs the requested operation.
4. The result (success or error) is returned to the program.
4
User Application (User Mode):
A program requests to open a file by calling a function such as open()
through an API
This occurs in user mode, where direct hardware access isn’t allowed.
System Call Interface:
The API function makes a system call to the OS through the system
call interface.
Each system call has a unique identifier number (i) that the OS
uses to recognize which service is requested.
The interface translates the request into a call that the kernel
understands.
Kernel Mode:
Control switches from user mode to kernel mode.
The kernel executes the actual implementation of the system call
Return Path:
Once the kernel finishes, it returns the result (success or error) through
the system call interface back to the user application.
Ways to transfer parameters between user and system layers:
1. Registers: Parameters passed through CPU registers.
2. Memory block: Parameters stored in a specific memory area; the
address is passed in a register.
3. Stack: Parameters pushed onto the program stack and popped by the
OS.
Types of system calls
• Process control
◦ end, abort
◦ load, execute
5
◦ create process, terminate process
◦ get process attributes, set process attributes
◦ wait for time
◦ wait event, signal event
◦ allocate and free memory
• File management
◦ create file, delete file
◦ open, close ◦ read, write, reposition
◦ get file attributes, set file attributes
• Device management
◦ request device, release device
◦ read, write, reposition
◦ get device attributes, set device attributes
◦ logically attach or detach devices
• Information maintenance
◦ get time or date, set time or date
◦ get system data, set system data
◦ get process, file, or device attributes
◦ set process, file, or device attributes
• Communications
◦ create, delete communication connection
◦ send, receive messages
◦ transfer status information
◦ attach or detach remote devices
4. System Programs
System programs make the computer easier to use by providing tools for
program development and execution.
Main Types
1. File Manipulation – Create, delete, copy, rename, print, or list
files/folders.
2. Status Information – Show system info (time, memory, disk
space, users, performance logs).
3. File Modification – Edit or search text files (using editors or
commands).
4. Programming Language Support – Include compilers,
assemblers, debuggers, and interpreters.
5. Program Loading and Execution – Tools to load, link, or debug
programs.
6. Communications – Enable user and system interaction (email, file
transfer, remote login).
7. Application Programs – General-purpose software for users (like
web browsers, word processors, etc.).
5. Operating System Structures
Simple structure
MS-DOS
6
Designed to use little memory and be fast.
Not divided into clear modules → all parts are closely connected.
Problem: Hard to modify or maintain because everything depends
on others.
UNIX Structure
Has two main parts:
o System programs – provide tools and utilities for users.
o Kernel – manages hardware and core functions (CPU, memory,
files, etc.).
Originally had limited structure because of old hardware.
Layered Approach
OS is divided into layers, each built on top of the lower one.
Bottom layer: hardware.
Top layer: user interface.
Each layer uses only the services of the layer below it.
Advantage: Easier to understand, debug, and modify.
Microkernel Structure
Moves most OS services to user space, leaving a small kernel that
handles:
o Low-level memory management
o Communication between processes
Uses message passing between components.
Pros: Easier to extend, more secure, more reliable.
Cons: Slower due to communication overhead.
Modular Approach (Modern Systems like Solaris, Linux, etc.)
The OS is made of modules that can be loaded or unloaded as
needed.
Each module:
o Is independent.
o Communicates through well-defined interfaces.
Advantage: Combines flexibility of microkernel and efficiency of
layered systems.
7
Hybrid Systems
Real-world OSs are hybrid, not purely one type.
They combine monolithic, modular, and microkernel features.
The goal is to balance speed, security, and flexibility.
Linux and Solaris
Monolithic kernels → all core OS services run in the same address
space → fast performance.
Also modular → new functionality can be added dynamically (e.g.,
loadable kernel modules).
Windows
Mostly monolithic for performance.
Includes microkernel-like behavior, supporting user-mode subsystems
called operating-system personalities.
Supports loadable kernel modules.
Example subsystems: Win32, POSIX, etc.
Mac OS X (macOS)
Hybrid layered architecture.
Top layers: Aqua GUI + Application environments (e.g., Cocoa for
Objective-C apps).
Kernel environment includes:
o Mach microkernel → memory management, IPC, RPC, scheduling.
o BSD kernel → file systems, networking, POSIX (Pthreads).
o I/O Kit → device drivers and loadable kernel extensions.
BSD environment can access kernel services directly.
iOS
8
Based on Mac OS X, but optimized for mobile devices.
Doesn’t run macOS apps directly.
Layered architecture:
1. Cocoa Touch (API for Objective-C) → supports touch, sensors, etc.
2. Media Services → graphics, audio, video.
3. Core Services → cloud, database, etc.
4. Core OS → kernel environment (Mach + BSD).
Android
Developed by the Open Handset Alliance (led by Google).
Open-source, runs on many devices (unlike iOS).
Layered architecture:
o Bottom: Modified Linux kernel → process, memory, driver, power
management.
o Android Runtime:
Core libraries
Dalvik Virtual Machine (optimized for mobile, runs
translated Java bytecode).
o Application Frameworks & Libraries:
Webkit (browser)
SQLite (database)
Multimedia
9
libc (lightweight C library for mobile CPUs).
6. Virtual Machines
A virtual machine makes a computer act like it has many separate
computers running inside it.
It does this by treating hardware and the OS kernel as if they were all
hardware.
Each VM runs its own operating system (called a guest OS).
The main OS that controls everything is the host OS.
So, one real machine → many virtual ones, each independent
How It Works
The host OS creates the illusion that each process (guest) has:
o Its own CPU, and
o Its own memory (virtual memory).
Each guest system believes it’s running on real hardware.
Benefits
Run multiple OSes on one computer (Windows, Linux, etc.).
Isolation: VMs don’t affect each other — one crash doesn’t crash
others.
Controlled sharing: You can allow some file or network sharing.
Networking: VMs can communicate with each other or with real
systems.
Development & testing: Safe way to test new systems or apps.
Resource consolidation: Combine many small systems into one
powerful host to save cost and space.
Compatibility: “Open Virtual Machine Format (OVF)” lets VMs run on
different host platforms.
REVIEW
1. What criteria are OS designers interested in when designing and
implementing an OS?
OS designers usually consider two main sets of goals:
User goals: System goals:
Easy to use Easy to design, implement,
Reliable and safe and maintain
Fast and efficient Flexible and reliable
Error-free
Efficient in resource use
2. What is the Java Virtual Machine (JVM)? Why do we install JVM
packages for each real machine type?
Java Virtual Machine (JVM):
The JVM is a virtual machine that runs Java bytecode.
It allows Java programs to run on any platform without modification.
Why different JVM packages are needed:
10
Because each real machine (hardware + OS) has a different CPU
architecture and system calls.
The JVM must be compiled and optimized for that architecture so it can
correctly interpret and execute Java bytecode on that platform.
QUESTIONS AND ANSWERS
2.4. What are the three major activities of an operating system with
regard to secondary-storage management?
The three major activities are:
1. Free-space management – Tracking which disk areas are free.
2. Storage allocation – Assigning space to files and programs.
3. Disk scheduling – Determining the order in which disk I/O requests are
processed
2.5. What is the purpose of the command interpreter? Why is it
usually separate from the kernel?
The command interpreter (shell) enables users to interact with the operating
system by entering commands to run programs, manage files, and configure
settings.
It is separate from the kernel because:
It is not essential for the OS core operation.
Separation allows the interpreter to be easily replaced or modified
(e.g., Bash, PowerShell) without affecting the kernel.
2.6. What system calls have to be executed by a command
interpreter or shell in order to start a new process?
A command interpreter or shell typically uses these system calls:
1. fork() – Creates a new process (copy of the shell).
2. exec() – Replaces the process memory with a new program to run.
3. wait() or waitpid() – Waits for the process to finish (optional).
4. exit() – Terminates the process after completion.
2.8. What is the main advantage of the layered approach to system
design? What are the disadvantages of the layered approach?
Advantages:
Easier design, debugging, and maintenance.
Each layer performs a specific function, promoting modularity and
encapsulation.
Changes in one layer have minimal effect on others.
Disadvantages:
Performance overhead due to communication between layers.
Difficult to define layers cleanly because some OS functions require
cross-layer interactions.
11
2.9. List five services provided by an operating system, and explain
how each creates convenience for users. In which cases would it be
impossible for user-level programs to provide these services?
Explain your answer.
Service Function / Convenience Why user programs
for Users cannot provide it
alone
Program Loads and runs programs Requires access to CPU
execution automatically and memory
management
I/O operations Provides easy access to Devices are protected
input/output devices from direct access
File-system Allows creating, reading, Requires control over
manipulation writing, and deleting files disk hardware
Communication Enables data exchange Needs kernel support for
between processes IPC mechanisms
Error detection Detects and responds to User programs lack full
hardware/software failures system visibility
2.10. Why do some systems store the OS in firmware, while others
store it on disk?
Stored in firmware:
Used in embedded systems or devices without disks, ensuring the OS
is always available and boots quickly.
Stored on disk:
Used in general-purpose systems, allowing the OS to be updated,
replaced, or customized more easily.
2.11. How could a system be designed to allow a choice of operating
systems from which to boot? What would the bootstrap program
need to do?
A system can support multiple OSs by using a bootstrap loader (boot
manager) stored in ROM or a small boot partition.
The bootstrap program must:
1. Initialize hardware (run POST).
2. Display a menu of available operating systems.
3. Load the selected OS kernel into memory and transfer control to it.
2.16. What are the advantages and disadvantages of using the same
system-call interface for manipulating both files and devices?
Advantages:
Uniform interface simplifies programming.
Easier to learn, extend, and maintain (read() and write() work for both).
Disadvantages:
May not fit device-specific operations.
12
2.17. Would it be possible for the user to develop a new command
interpreter using the system-call interface provided by the
operating system?
Yes. A user can create a new shell using existing system calls such as fork(),
exec(), open(), and read() — since these calls are sufficient to run programs
and manage files.
2.18. What are the two models of interprocess communication?
What are the strengths and weaknesses of the two approaches?
Model Description Strengths Weaknesses
Message Processes Works well for Slower for large data
passing communicate by distributed
sending messages systems; safe
Shared Processes share a Fast for large Requires
memory region of memory data transfers synchronization (risk
of race conditions)
2.20. It is sometimes difficult to achieve a layered approach if two
components of the operating system are dependent on each other.
Identify a scenario in which it is unclear how to layer two system
components that require tight coupling of their functionalities.
A typical example is the interaction between memory management and
process scheduling:
The scheduler depends on memory availability to make decisions.
Memory allocation may depend on which processes are currently
scheduled.
→ Their interdependence makes strict layering difficult.
2.21. What is the main advantage of the microkernel approach to
system design? How do user programs and system services interact
in a microkernel architecture? What are the disadvantages of using
the microkernel approach?
Advantages:
Easier to extend and maintain.
Improved security and reliability since most services run in user mode.
Interaction:
User programs and system services communicate using message
passing through the microkernel.
Disadvantages:
Performance overhead due to frequent user–kernel communication.
2.22. What are the advantages of using loadable kernel modules?
Allow dynamic addition of new functionality (e.g., device drivers)
without rebooting.
Make the kernel smaller and more flexible.
Simplify updates and maintenance.
2.23. How are iOS and Android similar? How are they different?
Aspect iOS Android Similarities
Base OS Derived from Modified Linux Both layered, hybrid
macOS (Mach + kernel structures
13
BSD)
Source Closed source Open source Both provide APIs for
model mobile app
development
Programmi Objective-C / Java / Kotlin with Both support rich
ng Swift with Cocoa Android SDK frameworks
Touch
App Apple App Store Google Play & Both use centralized
distribution only others app stores
Customizati Limited (Apple- Highly Both optimized for
on controlled) customizable smartphones and
tablets
14