Operating System Services and Components – Comprehensive Study Notes
1.1 Introduction to Operating SystemAn operating system (OS) is system software that manages, operates, and communicates with computer hardware and software.
The main job of the OS is to provide resources and services to user programs; without an OS, a computer is effectively useless.
The OS acts as an interface between the user and the hardware and controls execution of application programs.
The OS is also called a resource manager.
The CPU (processing unit) is the heart of the computer system; the OS allocates the processing unit (CPU) to user programs to complete execution.
The OS allocates memory to user programs as needed.
User programs interact with other user programs and devices (keyboard, mouse, joystick) via the OS.
1.1.1 Need of Operating System
Tasks performed by OS include identifying input from input devices (keyboard, mouse, etc.) and sending output to output devices (monitor, printer, etc.).
The OS keeps track of files and directories on disk and controls peripheral devices (secondary storage devices, printers, scanners, audio mixer).
The heart of the system is the CPU; the OS provides services to allocate the CPU to user programs.
The OS manages memory allocation to programs and provides resource sharing among programs.
1.1.2 Components of the Operating System
OS components have defined inputs and outputs and perform precise tasks to offer overall functionality.
Major OS functions include: 1) Process Management, 2) Memory Management, 3) File Management, 4) Device Management, 5) Protection and Security, 6) User Interface or Command Interpreter, 7) Booting the Computer, 8) Performs basic computer tasks.
Explain: Process Management; Memory Management; File Management; Device Management; Protection and Security; User Interface; Booting; Basic tasks.
1.1.3 Operations of the Operating System
Modern OS are interrupt-driven: OS sits idle waiting for events (I/O completion, interrupts). When an interrupt or trap occurs, events are signaled and handled.
Trap: abnormal condition detected during program execution (e.g., division by zero).
After handling an interrupt, OS performs housekeeping and resumes computation. The interrupt vector/table holds addresses of device drivers to service interrupts.
The design should limit the impact of a faulty/malicious program on other programs.
1.1.3(A) Dual Mode Operation
Most CPUs support at least two modes: kernel mode and user mode.
Kernel mode: all instructions allowed; entire register set accessible; OS code executes here.
User mode: memory/register access restricted; CPU switches to kernel mode to execute OS code.
A hardware mode bit indicates mode: mode = 0 for kernel mode; mode = 1 for user mode.
The only means to switch from user mode to kernel mode is via system calls as implemented by the OS.
When a user application requests service, transition from user mode to kernel mode occurs; during boot, hardware is in kernel mode, then switches to user mode after OS is loaded.
Privileged instructions (e.g., I/O control, timer management, interrupt management) can only be executed in kernel mode; attempts in user mode cause a trap.
System calls provide the interface between OS and user programs.
There are two ways a process can switch from user mode to kernel mode: (i) explicit system call request; (ii) OS may take over to perform housekeeping during execution.
ext{mode}{ ext{bit}} = 0 ightarrow ext{kernel mode}, \ ext{mode}{ ext{bit}} = 1
ightarrow ext{user mode}
1.1.3(B) Timer
A quartz crystal oscillator provides a periodic signal with high accuracy (usually in the
range of several hundred MHz to a few GHz).
A timer circuit uses a counter and holding register; a clock tick (interrupt) occurs when the counter reaches zero.
The time base is used to generate periodic interrupts, enabling the OS to schedule processes and manage time.
Clock synchronization: computers may store time in a battery-backed clock; Universal Coordinated Time (UTC) is used to synchronize clocks across machines.
The OS sets the timer interrupt before handing control to user applications to ensure timely scheduling.
1.1.4 Process Management (context and definitions)
A program in execution is a process; a process includes its execution context.
A process resides on disk (no resources) until scheduled; once in memory, it becomes a process with CPU state, memory contents, and execution environment.
The Process Manager implements process management functions.
In multiprogramming, a single CPU is shared among many processes; CPU utilization increases by keeping processes busy with I/O while other processes wait.
The OS uses CPU scheduling to allocate CPU time to processes.
Processes on multi-user systems are switched to give each user the illusion of exclusive use.
Process synchronization, interprocess communication, and deadlock handling are critical.
Program counter (PC) stores the address for resuming after a context switch.
Summary of Process Management activities:
Provide control access to shared resources (files, memory, I/O, CPU).
Control execution of user applications.
Create, execute, and delete processes.
Resume or cancel process execution.
Schedule processes.
Synchronization, IPC, and deadlock handling.
1.1.5 Resource Management
OS acts as a resource allocator: CPU time, memory, file storage, I/O devices, etc.
Resources are shared by multiple programs/users to save cost and enable data sharing.
The OS must decide:
How to allocate resources to processes, how to protect applications from each other, and how to ensure fair and efficient access.
How to operate and control various I/O devices.
1.1.6 Security and Protection
Security concerns include: accidental data loss, Trojan horses, trap doors, intruders (hackers), and data loss due to natural events or hardware/software errors.
Goals of protection: protect resources and data from unauthorized access while allowing legitimate use.
Threats and intruders:
Trojan horses: innocent-looking code that performs unauthorized actions when executed.
Trap doors: hidden code left by designers for quick access; potential holes if not removed.
Intruders: passive (read data) or active (modify data).
Accidental data loss causes: natural calamities, hardware/software errors, human errors.
Protection mechanisms and policies:
Reference monitor enforces protection by verifying access requests against policy.
Policies define what data should be protected from whom; mechanisms enforce those policies.
Protection domains: a collection of objects and rights; each domain corresponds to a user.
Access matrix maps domains to object rights (READ, WRITE, EXECUTE, etc.) and is used to determine permissible accesses.
Example: in Unix, a process is defined by a user-id (UID) and group-id (GID). Processes with the same UID/GID have identical object access.
Domain switching: processes may move from one domain to another (e.g., setuid programs); switching rules depend on the system.
1.1.6(A) Security Goals (overview)
Protection mechanisms focus on safeguarding resources within the interior environment.
Security involves considering external environment and operational conditions; total security is impossible, thus aims for exceptional breaches.
1.1.6(C) Protection Domains
System contains hardware objects (CPUs, memory segments, disks, printers) and software objects (processes, files, databases, semaphores).
Each object has a unique name; allowed operations per object per domain form a domain.
Example: Domain 1 may have READ on File A; Domain 2 may have READ/WRITE on File A; a process can switch domains during execution.
In Unix, processes are defined by UID and GID; kernel/domain transitions occur between user and kernel domains.
1.1.6(D) Access Matrix
Access control uses a matrix (domain vs object vs rights). The matrix determines if an access is permissible given the current domain.
Domains themselves can be treated as objects with an ENTER action (domain switching).
Fig. 1.1.2 shows a sample access matrix for domains and files.
1.1.7 Different Views of Operating System
Application View: OS services and execution environment; interfaces simplify hardware interactions; prevents undesirable interaction between concurrent programs.
User View: focuses on performance and usability; single-user systems vs multi-user systems; energy/power considerations in mobile devices.
System View: OS as resource manager; provides allocation/sharing control for processors, memory, disks, and I/O devices; some resources are sharable, some are not.
Implementation View: OS as a concurrent, real-time program; interaction with hardware; abstract entities include files, processes, threads, address spaces, sockets, pipes, etc.
1.2 Different Types of Operating Systems
Classification includes: Multi-user, Multiprocessing, Multitasking, Multithreading, Real-time.
1.2.1 Batch Operating System
Early mainframes used batch processing with punched cards; jobs grouped and executed without user interaction.
Scheduling by first-come, first-served; file access serial; minimal memory management due to memory sharing by the OS.
Pros: high CPU utilization for long-running jobs; cons: long waiting times for interactive use.
1.2.2 Multiprogrammed Operating Systems
Multiple processes reside in memory; CPU always has a runnable process, improving CPU utilization, especially for I/O-bound work.
Provides interactive response by switching among processes; creates illusion of parallelism.
1.2.3 Time Shared Systems
Time-sharing provides rapid CPU scheduling to multiple users; each user gets a small time quantum; context switching happens quickly to create the impression of simultaneous execution.
Example: server with multiple users or desktop OS with multitasking capabilities.
Modern personal OS support multiprogramming and time-sharing (e.g., UNIX, Linux, Windows, macOS).
1.2.4 Multiprocessor Systems
Support for multiple CPUs sharing a global memory; synchronization is required to ensure data consistency across CPUs.
Goal: high performance and hiding the number of CPUs from applications.
Synchronization primitives (semaphores, monitors) protect shared data; Windows and Linux are multiprocessor capable.
1.2.5 Mainframe Operating Systems
Mainframes have high I/O capacity (e.g., hundreds of disks); OS features include batch processing, transaction processing, and timesharing for large-scale workloads.
Linux-based replacements are increasingly used for some workloads.
1.2.6 Distributed Systems
Distributed OS aims to appear as a single coherent system over networks; shares resources and hides heterogeneity.
Definition: set of autonomous computers that appear to users as a single system.
Characteristics:
Heterogeneous architectures and data representations hidden from users
Internal organization hidden from users
Uniform interaction interface across time/space
Scalable and highly available with failure transparency
Motivation: resource sharing, speedup, reliability, and communication efficiency.
1.2.6(A) Definition of Distributed Systems
A distributed system is a set of autonomous computers connected by networks that appear as a single coherent system to users.
Characteristics include transparency, high availability, scalability, and consistent user interaction regardless of location/time.
1.2.6(B) Motivation
Resource sharing reduces costs (shared printers, files, etc.).
Computation speedup through parallel execution and load balancing.
Reliability through redundancy and seamless failover.
Communication among machines via protocol stacks; supports groupware, e-commerce, etc.
1.2.6(C) Types of Distributed OS
Tightly coupled systems (DOS): single global view of resources; hides hardware details; for multiprocessors and homogeneous multicomputer systems.
Loosely coupled systems (NOS): each node runs its own OS; coordination across heterogeneous systems; remote access and file transfer via network protocols.
1.2.7 Network Operating System (NOS) vs Distributed Operating System (DOS)
NOS: low transparency; remote login and remote file transfer (FTP); scalability is a main advantage; different nodes may run different OSes.
DOS: high transparency; aims for a single system image; inter-machine migrations and data/process mobility across sites; stronger focus on full resource transparency.
1.2.7 Real-Time Systems (confusion in notes; summarized here)
Real-time OS (RTOS) are characterized by hard real-time constraints (missed deadlines are unacceptable) or soft real-time constraints (missed deadlines may be acceptable in some cases).
Examples: VxWorks, QNX; used in control systems (air traffic control, industrial automation).
Key properties: fast, deterministic response; priority-driven scheduling; memory management tuned for predictability.
1.2.8 Mobile Operating Systems
Mobile OS are designed for phones, tablets, PDAs, etc.; constrained by battery life, memory, and processing power.
1.2.8(A) Android OS
Android combines open-source core with closed-source applications; AOSP (Android Open Source Project) is open source.
Goals:
Open-source platform for mobile devices; stable API for third-party apps.
Open-source foundation with strong proprietary app support; secure cross-application interaction.
User experience: quick interactions, multitasking, and app interoperability.
Architecture (layered): Applications, Application Framework, Android Run Time, Libraries, Linux Kernel.
1.2.8(B) Android Architecture
Applications layer (Java): Dialer, SMS/MMS, Browser, Camera, etc.
Application Framework layer (APIs): Activity Manager, Window Manager, View Manager, Content Manager, Notification Manager, Package Manager, Telephony Manager, Resource Manager, Location Manager, etc.
Libraries layer (JNI-enabled): Surface Manager, OpenGL, SQLite, Media Framework, SSL, FreeType, etc.
Android Run Time: Dalvik Virtual Machine (DVM) and Core Libraries; DVM compiles dex bytecode for limited-resource devices.
Linux Kernel: underlying kernel (2.6) with drivers (display, camera, Bluetooth, memory, binder, WiFi, USB, keypad, audio, power management).
1.2.9 iOS (and related notes)
iPhone OS (iOS) is a mobile OS from Apple; multi-threaded applications; security model via system daemons and keychains.
Applications are built with iOS SDK and use threads for concurrency; each thread has its own stack; kernel schedules threads.
iOS architecture includes units for security protocols (Keychain, Trust services) and runtime for compiled code.
1.2.10 Difference between Time-Sharing and Real-Time Systems (summary)
Time-sharing: provides quick responsiveness to multiple users; focus on throughput and interactivity; “small quantum” of CPU time per user.
Real-time: deadlines are critical; hard vs soft RT; guarantees on response time; used in safety-critical applications.
1.3 Command Line Based vs GUI Based Operating Systems
1.3.1 DOS (Disk Operating System)
DOS is a single-user, non-graphical, line-oriented/menu-driven OS.
MS-DOS: historical example; simple interface, less user-friendly than GUI systems.
Versions: 2.0, 3.0, 3.2, 4.0, 5.0, 6.0, 6.2, 6.22, 7.0, 7.2.
System files: MSDOS.SYS (kernel and file system support), IO.SYS (I/O system), COMMAND.COM (command interpreter), CONFIG.SYS (boot-time configuration).
Features: single-user, single-tasking; CLI; internal/external commands; supports EXE, COM, BAT files; hierarchical directories; 8086 assembly language; 8.3 filename convention; FAT-like file naming.
1.3.1(A) Directory Structure in DOS
Root directory denoted by \; directories form an inverted tree; each directory entry is 32 bytes.
Directory entry structure includes: file name, extension, attributes, reserved area, time, date, starting cluster, file size.
1.3.1(B) File Structure in DOS
Directory entry contains 32 bytes; fields: primary name (8), extension (3), file attribute (1), reserved (10), time (2), date (2), starting cluster (2), file size (4).
Files are identified by primary name and extension; extension optional; filenames are not case-sensitive; invalid characters listed (e.g., ? ^ . " / \ [ ] : < > + = , ; space).
File Control Block (FCB) contains 37 bytes with fields like driver id, file name, extension, current block, record size, file size, timestamps, etc.
1.3.1(C) Internal and External Commands in DOS
Internal commands: loaded with COMMAND.COM; executed directly; e.g., copy, rename, erase, dir, cd.
External commands: require executable files on disk; used for more complex tasks (formatting, joining files, etc.).
1.3.2 UNIX
UNIX origin: Bell Labs; designed to be simple, graceful, and consistent; philosophy of doing one thing well and avoiding redundancy; layers: system hardware, UNIX kernel, standard library, standard utilities, shell.
Goals: portability, simplicity, power, and consistency; principles like least surprise.
1.3.2(A) UNIX Goals and Design Principles
UNIX provides facilities for collaboration and sharing; simple, graceful design; each program should do one thing well.
Interfaces: true system call interface, library interface, utilities interface.
1.3.2(B) Interfaces to UNIX
Layers: System hardware, UNIX kernel, Standard library, Standard utilities, User.
User programs access OS services via system calls or libraries; standard utilities (shell, editors, compilers) provide high-level interaction.
1.3.2(C) UNIX Shell
Shell is the command-line interface (e.g., Bourne shell, ksh, bash).
Shell starts, prints a prompt, takes a command line, extracts the first word as program name, runs it, then awaits the next command.
1.3.2(D) UNIX Utility Programs
Utilities categorized as: file/directory manipulation, filters, development tools, text processing, system administration, etc.
POSIX standard (1003.2) defines syntax/semantics for many utilities to ensure script portability across UNIX systems.
Examples include: cp, mv, cat, chmod, ls, mkdir, rm, etc.
1.3.2(E) Information, File, Process/Memory Management Overview
UNIX kernel divided into: Information Management and Process Management.
Memory management closely tied to process management; devices treated as files via /dev; driver interfaces exist for devices.
Process execution can be user mode or kernel mode; system calls or interrupts switch to kernel mode; CPU-bound vs I/O-bound processes get different priorities; round-robin scheduling for equal-priority processes; swapping and demand paging for memory management.
Data structures: U-area (process data structures), user stack, kernel stack, process table; memory management includes swapping and paging.
Kernel provides system call interface; device drivers are accessed via this interface; file system handles data transfer between memory and external devices; disk cache is used for block transfers.
UNIX traditionally single-processor oriented; modular and extensible through new versions.
1.4 GUI Based Operating System
1.4.1 Windows History
Windows evolved from MS-DOS GUI shells to a modern 32-bit OS; Windows NT family introduced in 1993 with Windows NT 3.1; Windows 4.0, Windows 2000, Windows XP, Windows Vista, Windows 7, etc.
Design goals for Windows included security, reliability, application compatibility, high performance, extensibility, portability, internationalization, and energy efficiency.
Features include: built-in DOS/50 compatibility, large number of device drivers, GUI, multitasking, plug-and-play, fonts and language support, clipboard data transfer.
1.4.1(A) Windows System Components
Layered architecture: HAL (Hardware Abstraction Layer), kernel, executive; all kernel mode; user-mode subsystems for environment and protection.
HAL hides hardware differences; Kernel handles thread scheduling, synchronization, interrupt handling, and kernel/user mode switching.
Executive: core OS services in C; components include Object Manager, I/O Manager, Process Manager, Virtual Memory Manager, Security Reference Monitor, Cache Manager, Plug-and-Play Manager, Power Manager, Registry, etc.
1.4.2 Linux
History: MINIX inspired microkernel; Linus Torvalds created Linux with a monolithic kernel but modular architecture via loadable modules.
Features: open-source, GUI via X Window System, multi-user, multithreading, multitasking, networking, portability, and broad hardware support.
1.4.2(C) Components of Linux
Three main code bodies: Kernel, System libraries, System utilities.
Kernel: core abstractions (processes, memory), interacts with hardware via drivers.
System libraries: standard APIs used by applications to interact with the kernel.
System utilities/daemons: programs that perform management tasks; initialization and configuration utilities.
Module mechanism: loadable modules (device drivers, file systems) loaded/unloaded at runtime; dynamic linking enables modularity.
1.4.3 Mac OS
macOS: GUI-based UNIX-like OS from Apple; combines UNIX core with modern GUI; supports development with Xcode; strong security and stability features.
Features: Aqua GUI, multitasking, security (Gatekeeper, FileVault, sandboxing), energy efficiency, broad language/tool support.
1.4.4 MS-DOS vs Windows
MS-DOS: CLI, single-user, single-tasking, limited networking, less user-friendly; FAT16; max partition size ~2 GB.
Windows: GUI, multitasking, multi-user, large partition support (e.g., FAT32 and beyond), networking, PnP, extensive fonts/languages support.
1.4.5 GUI vs CUI (CLI)
GUI advantages: user-friendly, icons/menus, pointing devices, easier navigation, rich visual interfaces.
CLI advantages: scriptability, compactness, lower resource usage; often used in MacOS Terminal or Linux shells.
1.4.6 Advantages of Linux/UNIX over Windows
UNIX/Linux: broader architecture support (mainframes to microcomputers); stability and lower maintenance; stronger security and access control; better processing capability; generally free or open-source.
UNIX/Linux are primary servers and internet backbone (e.g., Apache runs on UNIX/Linux for ~90% of the Internet).
Open-source ecosystem supports modular development and rapid software upgrades without licensing costs.
1.5 Services Provided by Operating System (Overview)
The OS provides six core services to enable efficient program execution:
1) User Interface
2) Program Execution
3) I/O Operations
4) File System Manipulation
5) Communications
6) Error DetectionAdditional summary:
All modern OS provide a UI (CLI or GUI).
The OS provides an environment to run programs efficiently, including memory allocation, process scheduling, and multitasking.
The OS abstracts hardware details from applications via system calls and libraries.
1.6 System Calls
1.6.1 Concepts of System Calls
System calls define the interface between user programs and the OS; they allow the OS to perform tasks on behalf of a program.
From the programmer’s viewpoint, a system call looks like a normal function call, but it transfers control to the kernel.
The kernel saves the user process context, validates the request, ensures proper privileges, and may access or modify memory/Data as needed. After completion, control returns to the calling program.
The system call interface is layered: user applications --(system calls)--> kernel; kernel interacts with device drivers and hardware.
Privileged operations can only be executed in kernel mode; user mode attempts trap to the OS.
1.6.2 Types of System Calls
System calls are categorized into five groups:
1) Process control
2) File manipulation
3) Device manipulation
4) Information maintenance
5) CommunicationsExamples of system call actions include: create/terminate processes, open/close files, read/write, get/set attributes, allocate/free memory, etc.
Example System Calls (typical and representative)
Open: request to use a file; returns a file descriptor or -1 on failure; error code in errno.
Close: release a file descriptor.
Read: read bytes from a file descriptor into a buffer.
Write: write bytes from a buffer to a file descriptor.
Create Process: spawn a new process; establishes a parent-child relationship; may create further descendants.
1.6.3 System Call Invocation Details
System calls can be invoked by passing parameters via registers, memory blocks, or the stack.
The precise method varies by OS (e.g., Linux/Solaris use memory blocks or stack for parameters).
1.7 OS Components
1.7.1 Responsibilities of OS Components (Overview)
Memory management, File management, I/O system management, Secondary storage management, and overall resource management.
A robust OS provides proper memory allocation/deallocation, process scheduling, synchronization, and inter-process communication.
1.7.2 Main Memory Management
Main memory is needed to execute programs; memory is volatile; secondary storage is non-volatile.
A process requires memory for code, stack, heap, and data; these reside in main memory during execution.
Memory manager is responsible for moving processes between memory and secondary storage (swapping) and for allocating/freeing memory blocks.
Critical concepts: address space, memory protection, swapping, paging/demand paging, and memory usage tracking.
1.7.3 File Management
File management includes creation/deletion of files and directories, access to files, storage allocation, backup, and file security.
Files are the persistent storage abstraction; data may be stored in directories with hierarchical structure.
File system primitives provide manipulation facilities to users and programs.
1.7.4 I/O System Management
I/O is a major OS function, involving device control, interrupt handling, error management, and a simple, uniform interface to devices.
Core I/O components include buffering, caching, spooling, device driver interface, and specific device drivers.
1.7.5 Secondary Storage Management
Secondary storage types: magnetic ( disks, tapes ) and optical (CD/DVD);
Hard disks: platters, read/write heads, cylinders, tracks, sectors; disk cache improves I/O performance.
Storage management concerns include large-scale storage, partitioning, and data organization for efficient access and reliability.
Review Questions (Topics to Prepare)
What is operating system? Why is it needed? Explain the components and operations of an OS.
Explain dual-mode operation and the concept of privileged operations.
Describe program management, resource management, protection and security.
Explain protection domains and access matrices with examples (e.g., Unix UID/GID, domain switching).
List and explain different views of an OS: application, user, system, and implementation views.
Distinguish between various OS types: batch, multiprogramming, time-sharing, multiprocessing, mainframe, distributed, NOS vs DOS, mobile OS.
Describe Android OS architecture and its design goals; outline Android run-time components and Linux kernel role.
Compare GUI-based vs CLI-based operating systems; discuss advantages of Linux/UNIX vs Windows.
Explain UNIX history, goals, shell, and utility programs; discuss UNIX file and process management.
Explain Windows architecture (HAL, kernel, executive) and Windows system components.
Explain Linux architecture, features, and modular kernel with loadable modules.
Define and illustrate system calls, their types, and examples (open, read, write, create process, etc.).
Outline main memory management, file management, I/O management, and secondary storage management responsibilities.
What is real-time OS? Distinguish hard vs soft real-time, and give examples of RTOS.
Explain distributed vs network operating systems, including transparency, scalability, and data/process migration.
Explain _ (additional topics from the notes include Android/iOS architecture, UNIX interfaces, and Windows components).
Formula highlights:
Dual-mode transition: ext{mode}{ ext{bit}} = 0 ightarrow ext{kernel mode}, \ ext{mode}{ ext{bit}} = 1
ightarrow ext{user mode}Clock and timer concepts: clock frequency is generally f ext{ in the range } [10^8, 10^9] ext{ Hz}; timer counters generate clock ticks.