Operating System — UT1 Notes

Prepared from OS Module 1 and OS Module 2 study material. The diagrams are simplified exam diagrams; redraw them neatly and label every layer/state.

1. Functions performed by an Operating System (OS Functions)

An Operating System (OS) is system software that acts as an interface between the user and computer hardware. It manages hardware/software resources and provides an environment in which application programs can execute.

Main functions

  1. Process management: Creates and terminates processes, schedules CPU time, performs context switching, and coordinates processes.
  2. Memory management: Keeps track of memory usage, allocates and deallocates RAM, and prevents one process from corrupting another process’s memory.
  3. File management: Creates, names, stores, opens, reads, writes, copies, moves, and deletes files and directories. It also manages file permissions.
  4. Device and I/O management: Controls keyboards, printers, disks, cameras, network cards, and other devices through device drivers. It allocates and releases devices when required.
  5. Secondary-storage management: Organizes free space and allocates disk space for files and programs.
  6. Protection and security: Authenticates users, enforces access permissions, protects data, and supports encryption and secure access.
  7. User interface: Provides a GUI (windows, icons, menus), CLI (commands), or touch interface.
  8. Communication and networking: Allows processes and computers to exchange data using pipes, shared memory, sockets, and network services.
  9. Error detection and handling: Detects CPU, memory, I/O, file, and application errors and takes corrective action.
  10. Resource allocation and accounting: Shares CPU, memory, storage, and devices fairly and records resource usage.

Basic view

flowchart TB
    U[Users and application programs] --> I[System programs and system-call interface]
    I --> K[Operating-system kernel]
    K --> H[Hardware: CPU, memory, storage and devices]

In short: the OS makes hardware usable, shares it efficiently, and protects it from incorrect or unauthorized use.


2. Evolution of Operating Systems

Evolution timeline

YearStage
1940First Generation
1955Second Generation
1965Third Generation
1980Fourth Generation
1990Modern Operating Systems
TodayModern Operating Systems

First Generation (1940–1955)

ItemEasy pointer
Operating systemNo operating system
FeaturesVacuum tubes
Machine language
Manual programming
No GUI
ProblemsSlow
Difficult
One program only

Second Generation (about 1955–1965)

ItemEasy pointer
Operating systemBatch operating system
DefinitionUsers submitted jobs using punch cards.
Computer executed all jobs automatically.
AdvantagesBetter CPU utilization
Reduced setup time
DisadvantageNo interaction
ExampleElectricity bill generation

Third Generation (about 1965–1980)

ItemEasy pointer
TechnologyMultiprogramming
FeaturesMultiple jobs stored in RAM
CPU switches rapidly
Better performance
AdvantagesHigh CPU utilization
Reduced waiting time
Time-sharing OSMany users use one computer simultaneously
ExamplesUniversity Labs
Banking

How multiprogramming works

StepEasy pointer
1Multiple programs are loaded into the main memory (RAM).
2The CPU executes one program for a short interval.
3When that program waits for input/output (I/O), the CPU switches to another program.
4This keeps the CPU busy and improves overall system performance.

Everyday analogy

StepChef analogy
1The chef starts cooking rice.
2While the rice is boiling, the chef prepares vegetables.
3While the vegetables are cooking, the chef makes chapati.
4While the chapati is on the pan, the chef prepares dessert.

Fourth Generation (1980 onward)

ItemEasy pointer
Operating systemGUI operating systems
ExamplesWindows
macOS
Linux
FeaturesMouse
Icons
Windows
Networking

Modern Operating Systems (1990s–Today)

ItemEasy pointer
ExamplesAndroid
iOS
ChromeOS
Embedded Linux
IoT OS
ApplicationsSmartphones
Cars
Smart TVs
Smart Watches

Evolution summary table

GenerationTechnologyExample
1No OSENIAC
2BatchIBM
3MultiprogrammingUNIX
4GUIWindows
5CloudAndroid

3. Operating System Structures

OS structure means the way the internal components of an operating system are organized and how they communicate with one another.

Common structure diagram

flowchart TB
    A[Application programs] --> S[System programs and APIs]
    S --> C[System-call interface]
    C --> K[Kernel: process, memory, file and device management]
    K --> H[Hardware]

Types of OS structures

1. Simple structure

  • There is little separation between application support, system programs, drivers, and the kernel.
  • It can be fast because components communicate directly.
  • It is difficult to maintain, extend, and debug.
  • Example: MS-DOS.

2. Monolithic structure

  • Most OS services—process management, memory management, file systems, device drivers, and networking—run in one large kernel address space.
  • It provides good performance, but a bug in one kernel service can affect the whole system.
  • Traditional UNIX is a common example; Linux is generally described as a modular monolithic kernel.

3. Layered structure

Each layer uses the services of the layer below it. A simplified model based on the presentation is:

flowchart TB
    L6[Layer 6: User programs]
    L5[Layer 5: I/O buffer and services]
    L4[Layer 4: Process management]
    L3[Layer 3: Memory management]
    L2[Layer 2: CPU scheduling]
    L1[Layer 1: Hardware]
    L6 --> L5 --> L4 --> L3 --> L2 --> L1
  • Advantages: clear separation, easier testing, debugging, and maintenance.
  • Limitation: extra layer-to-layer communication can reduce performance or make design difficult.

4. Microkernel structure

  • Only essential services such as basic scheduling, IPC, and low-level memory management remain in the kernel.
  • File systems, device drivers, and other services run as user-level servers.
  • Advantages: reliable, secure, easier to debug and extend.
  • Limitation: communication between user services and the kernel can add overhead.
  • Examples: MINIX and QNX.

5. Modular structure

  • A small core kernel loads or unloads modules when required.
  • Modules can provide file systems, drivers, or networking support without rebuilding the complete kernel.
  • Advantages: flexible, easy to update, and usually retains good performance.
  • Example: Linux loadable kernel modules.

6. Hybrid structure

  • Combines ideas from monolithic and microkernel designs.
  • It keeps performance-critical services close to the kernel while separating or modularizing other services.
  • Examples: Windows and macOS.
  • Benefit: attempts to combine high performance with reliability and security.

Mnemonic for the structures

Silly Little Monkeys Make Honey

LetterStructure
SSimple
LLayered
MMicrokernel
MModular
HHybrid

Ratings in ascending order

Low → Medium → High → Very High

StructureRelative speedSecurity / isolationFlexibility
LayeredMediumHighMedium
MicrokernelMediumVery HighHigh
SimpleHighLowLow
ModularHighHighHigh
HybridVery HighHighHigh

4. Services provided by an OS to users and programs

ServiceWhat the OS doesExample
User interfaceAccepts commands, clicks, or touch input and displays outputWindows GUI, Linux terminal, Android touch screen
Program executionLoads a program, allocates required memory, starts it, and terminates itOpening Microsoft Word or Chrome
I/O operationsProvides a controlled way for programs to use input/output devicesReading the keyboard or printing a document
File-system manipulationCreates, deletes, opens, closes, reads, writes, renames, copies, and moves files; applies permissionsSaving a file in Google Drive or Windows Explorer
CommunicationAllows processes on the same computer or different computers to exchange dataPipes, shared memory, sockets, messaging
Error detectionDetects and reports hardware, memory, disk, I/O, and program errorsReporting a disk-read error
Resource allocationDecides which process receives CPU, RAM, storage, network, or a devicePlaying YouTube while downloading a file
Protection and securityAuthenticates users and controls access to programs, memory, files, and devicesPassword or fingerprint login; app permissions

These services hide hardware complexity from programs. An application usually requests them through an API and system calls instead of controlling hardware directly.


5. System Calls and their types

A system call is a controlled mechanism through which a user program requests a service from the operating-system kernel. It is the interface between an application and privileged OS operations.

System-call flow

flowchart LR
    A[User program: Save] --> C[System call: write]
    C --> T[Trap / switch to kernel mode]
    T --> K[Kernel validates request and performs service]
    K --> D[Hardware: disk or device]
    D --> K
    K --> R[Return result or error]
    R --> A

For example, when Save is clicked in Word, Word asks the OS to perform a write() operation. The application cannot directly write to the disk because the OS must check permissions, file state, and device access.

Six major types

TypePurposeCommon examples
Process controlCreate, execute, wait for, suspend, resume, and terminate processesfork(), exec(), wait(), exit()
File managementCreate, open, close, read, write, and delete filesopen(), read(), write(), close(), unlink()
Device managementRequest/release a device and read from or write to itDevice I/O requests, printer and keyboard operations
Information maintenanceGet or set time, date, system data, process ID, and accounting informationgetpid(), time()
CommunicationExchange messages, use pipes, shared memory, or socketspipe(), shared-memory calls, send()/recv()
Protection / securityAuthenticate users and manage permissions and protected resourceschmod(), permission checks, password verification

System call versus ordinary function

An ordinary library function runs in user space. A system call causes a controlled transition to kernel mode because it may access protected resources. Libraries such as the C standard library often provide a convenient wrapper around system calls.


6. System programs with examples

System programs are utility programs supplied with or used alongside an OS. They provide a convenient, higher-level environment for users and developers.

CategoryPurposeExamples
File-management programsCopy, move, rename, delete, and organize filesWindows File Explorer, Linux file manager
Status-information programsDisplay date, time, CPU, memory, disk, and process usageWindows Task Manager, Linux System Monitor
File-modification programsCreate and edit text or documentsNotepad, Microsoft Word, VS Code
Programming-language supportCompile, interpret, assemble, and debug programsGCC, javac, Python interpreter
Program loading and executionLoad executable files and start applicationsShell, program loader, double-clicking Chrome
Communication programsSupport communication over networksChrome, Outlook, Zoom, Microsoft Teams
Background services / daemonsRun continuously and perform system tasksWindows Update, antivirus service, print spooler, Bluetooth service

System calls versus system programs

System callsSystem programs
Low-level interface between an application and the kernelHigher-level utilities used by users or administrators
Usually entered through a controlled kernel-mode transitionNormally execute as user-space programs
Example: open(), read(), write()Example: File Explorer, Task Manager, GCC

7. Concept of a Virtual Machine (VM)

A Virtual Machine (VM) is a software-based computer that behaves like a physical computer. It is given virtual CPU, memory, storage, and devices and can run its own guest operating system inside a physical computer.

VM structure

flowchart TB
    HW[Physical host hardware] --> HOS[Host operating system]
    HOS --> HV[Hypervisor: VirtualBox, VMware or Hyper-V]
    HV --> VM1[Virtual machine 1: virtual CPU, RAM and disk]
    HV --> VM2[Virtual machine 2: virtual CPU, RAM and disk]
    VM1 --> G1[Guest OS: Kali Linux]
    VM2 --> G2[Guest OS: Ubuntu or Windows Server]
    G1 --> A1[Guest applications]
    G2 --> A2[Guest applications]

The diagram shows a hosted/Type-2 arrangement. A Type-1 hypervisor can run directly on physical hardware in servers.

Components

  • Host machine: the physical computer, such as a Dell laptop.
  • Host OS: the OS installed on the physical computer, such as Windows 11, Ubuntu, or macOS.
  • Hypervisor: software that creates and manages VMs, allocates resources, and isolates guests.
  • Guest OS: the OS running inside a VM, such as Kali Linux, Ubuntu, or Windows Server.

Uses and advantages

  • Runs multiple operating systems on one computer.
  • Tests software safely without damaging the host OS.
  • Provides snapshots for easy backup and recovery.
  • Improves server utilization and reduces hardware cost.
  • Supports cloud computing, server consolidation, network simulation, education, and disaster recovery.
  • Isolates a guest from the host and from other guests.

Limitation

A VM normally has lower performance than a physical machine and needs extra RAM, CPU time, and storage. Running many VMs at once can reduce performance.

Real-world example: cyber-security lab

A student can keep Windows 11 as the host, install Oracle VirtualBox, create a Kali Linux VM, and allocate about 4 GB RAM and 40 GB storage. The student can practise Nmap, Wireshark, and Metasploit in the isolated VM. If the VM crashes or becomes infected during a permitted lab exercise, the host system can remain protected.


8. Mobile OS and types of Mobile OS

A Mobile Operating System (Mobile OS) is system software designed for smartphones, tablets, smartwatches, and other portable devices. It manages hardware, applications, memory, communication, security, and power while providing a touch-friendly interface.

Mobile OSDeveloper / organizationMain description
AndroidGoogle / Open Handset AllianceOpen-source-based, widely used on phones, tablets, TVs, and other devices; has the Google Play ecosystem
iOSAppleClosed-source mobile OS used on iPhones; tightly integrated with Apple hardware and services
HarmonyOSHuaweiDistributed OS for phones, wearables, and IoT devices
KaiOSKaiOS TechnologiesLightweight OS used mainly in feature phones
TizenSamsung and partnersUsed in smart TVs, wearables, and some embedded devices

Historical development

Palm OS and Symbian were important early PDA/smartphone systems. BlackBerry OS focused on secure email and enterprise communication. Apple introduced iOS and the modern multi-touch/App Store model in 2007; Android followed in 2008 and became the most widely used mobile OS. Windows Phone and later HarmonyOS added other approaches.


9. Functions of a Mobile OS

  1. Process management: Manages running apps, supports multitasking, and controls background activity.
  2. Memory management: Allocates RAM to apps, frees unused memory, and prevents apps from interfering with one another.
  3. File management: Organizes files and folders and provides secure internal or removable storage.
  4. Device management: Controls the camera, microphone, display, speakers, Bluetooth, sensors, GPS, Wi-Fi, NFC, and USB through drivers and interfaces.
  5. Security management: Provides login/authentication, app sandboxing and permissions, encryption, secure boot, and app verification.
  6. Network management: Manages Wi-Fi, mobile data, Bluetooth, hotspot, VPN, and handover between networks.
  7. Power management: Optimizes battery use, controls sleep mode and background work, and supports charging features.
  8. User interaction: Provides touchscreen, multi-touch gestures, notifications, widgets, voice assistants, and accessibility tools.
  9. Location and media support: Provides standard services for GPS navigation, camera, audio, video, and cloud synchronization.

10. Architecture of a Mobile OS

General mobile-OS model

flowchart TB
    A[Applications layer: system apps and user apps]
    F[Application framework: activity manager, view system, package manager]
    M[Middleware: libraries, runtime, media and security services]
    H[Hardware abstraction layer: camera, audio, Bluetooth and sensor HALs]
    K[Kernel: processes, memory, power and device drivers]
    HW[Hardware: CPU, memory, display, sensors and radio]
    A --> F --> M --> H --> K --> HW

Role of each layer

  • Applications layer: contains built-in apps and user-installed apps.
  • Application framework: gives apps reusable services such as activity management, content providers, view/display services, and package management.
  • Middleware/libraries/runtime: provides standard libraries, media support, security services, and the environment in which apps run.
  • HAL: hides hardware-specific details behind standard interfaces.
  • Kernel: manages processes, memory, power, drivers, files, and communication with hardware.
  • Hardware: includes the processor, RAM, storage, screen, camera, sensors, Wi-Fi, Bluetooth, and cellular radio.

Android architecture model

flowchart TB
    A[System and user applications]
    J[Java API application framework]
    R[Android Runtime: ART]
    N[Native C/C++ libraries]
    H[Hardware Abstraction Layer: HAL]
    K[Linux kernel: drivers, process, memory and power management]
    A --> J
    J --> R
    J --> N
    R --> N
    N --> H --> K

The Android kernel is based on Linux. The framework and runtime provide common services, while native libraries and the HAL connect them to device hardware.

iOS layer names for comparison

iOS is commonly represented from top to bottom as Cocoa Touch → Media Services → Core Services → Core OS → hardware. The names differ, but the idea is the same: applications use high-level frameworks, which use lower-level services, the kernel, and hardware.


11. What is meant by a Process?

A process is a program in execution. It is an active, dynamic entity loaded into main memory and given CPU time and other resources by the OS.

ProgramProcess
Passive set of instructionsActive program currently executing
Stored on secondary storageLoaded into main memory for execution
Static and does not have a stateDynamic and moves through states such as ready, running, and waiting
Does not need the CPU while inactiveNeeds CPU time during execution
Example: chrome.exe stored on diskA running Chrome instance

The OS creates a process when a program is started, schedules it, gives it resources, and releases those resources when it terminates.


12. Process concepts with a diagram

Process components

A process normally contains:

  • Code / text: executable program instructions.
  • Data: global and static variables.
  • Heap: memory requested dynamically during execution.
  • Stack: function calls, parameters, return addresses, and local variables.
  • Program counter (PC): address of the next instruction.
  • CPU registers: temporary values required by the CPU.
  • I/O status: devices and files allocated to the process.

Process creation and execution

flowchart LR
    P[Program file on disk] -->|OS loads it| M[Process in main memory]
    M --> C[Code, data, heap and stack]
    M --> PCB[Process Control Block]
    PCB --> CPU[Scheduler and CPU execute the process]

Process memory layout

flowchart TB
    S["High addresses: STACK<br/>Function calls and local variables<br/>Grows downward"]
    H["HEAP<br/>Dynamically allocated memory<br/>Grows upward"]
    D["DATA<br/>Global and static variables"]
    C["Low addresses: CODE / TEXT<br/>Program instructions"]
    S --> H --> D --> C

Process Control Block (PCB)

The OS maintains one PCB for each process. It is like the process’s identity card and record book.

PCB fieldMeaning
Process ID (PID)Unique identification number
Process stateNew, ready, running, waiting, or terminated
Program counterAddress of the next instruction
CPU registersSaved CPU values when the process is not running
CPU-scheduling informationPriority, queue pointers, and time-slice information
Memory-management informationBase/limit, page-table, or other memory details
I/O status informationOpen files and allocated devices
Accounting informationCPU time, start time, and usage statistics

During a context switch, the OS saves the current process’s CPU state in its PCB and restores the saved state of another process.

Process operations

  • Creation: a parent process creates a child process.
  • Scheduling/dispatch: the scheduler selects a ready process for the CPU.
  • Blocking: a running process waits for I/O or an event.
  • Wake-up: completion of the event moves it back to the ready queue.
  • Suspension and resumption: the OS temporarily stops and later restarts a process, often due to memory pressure or user request.
  • Termination: the process exits, fails, is closed by the user, or is stopped by the OS; its memory and resources are released.

13. Life cycle of process states

The five major states are New, Ready, Running, Waiting/Blocked, and Terminated.

flowchart LR
    N[New] --> R[Ready] --> X[Running] --> T[Terminated]
    X --> W[Waiting / Blocked]
    W --> R
    X --> R
TransitionMeaning
New → ReadyProcess is admitted
Ready → RunningCPU scheduler dispatches it
Running → Waiting / BlockedIt waits for I/O or an event
Waiting / Blocked → ReadyI/O or event completes
Running → ReadyInterrupt or time slice expires
Running → TerminatedExit, error, or close

State meanings

  • New: the process is being created.
  • Ready: the process is in memory and waiting for CPU allocation.
  • Running: the CPU is currently executing its instructions.
  • Waiting/Blocked: it cannot continue until I/O or another event completes.
  • Terminated: execution is complete or the process has been stopped; the OS cleans up its resources.

Optional suspended states

When memory or system load is high, the OS may move a ready or waiting process to a suspended state. A suspended process is not eligible for normal execution until it is resumed and returned to the ready queue.


14. Client–Server communication: Sockets and RPC

In client–server communication, the client requests a service and the server provides it.

flowchart LR
    C[Client process] -->|request| S[Server process]
    S -->|response / result| C

A. Sockets

A socket is a communication endpoint through which processes exchange data on the same machine or across a network. A network socket is identified by an IP address, port number, and protocol.

Socket communication flow

flowchart LR
    C["Client: socket and connect"] -->|send request| E["Network and socket endpoints<br/>IP address + port"]
    E --> S[Server: bind, listen and accept]
    S -->|send response| E
    E -->|receive result| C
  • TCP socket: connection-oriented and reliable; commonly used by web servers.
  • UDP socket: connectionless and faster, but delivery and ordering are not guaranteed.
  • Typical TCP server sequence: socket → bind → listen → accept → send/receive → close.
  • Typical client sequence: socket → connect → send/receive → close.

Example: a browser connects to a web server using a socket, sends an HTTP request, and receives the web page.

B. Remote Procedure Call (RPC)

RPC allows a program to call a procedure or function on another computer as if it were a local function. The RPC system hides most networking details.

flowchart LR
    C["Client program<br/>getBalance(accountNo)"] --> CS["Client stub<br/>marshal arguments"]
    CS --> N["Network / transport"]
    N --> SS["Server stub<br/>unmarshal arguments"]
    SS --> P["Remote procedure on server"]
    P --> SS
    SS --> N
    N --> CS
    CS --> C

RPC steps

  1. The client calls a local-looking function.
  2. The client stub marshals (packs) the arguments into a message.
  3. The message travels through the network.
  4. The server stub unmarshals the arguments and calls the server procedure.
  5. The result is packed and returned to the client.

Example: a mobile-banking app calls getBalance(accountNo); the bank server performs the operation and returns the balance.

Socket versus RPC

PointSocketRPC
AbstractionLow-level communication endpointHigh-level remote function call
Programmer managesConnections, messages, bytes, and protocolFunction interface and arguments; framework handles much of the messaging
Typical useWeb, chat, streaming, custom network protocolsDistributed applications and service APIs
ExampleBrowser sends an HTTP request through TCPBanking app calls a remote getBalance() procedure

15. Multithreading models

A thread is the smallest unit of CPU execution within a process. Threads of the same process share its code, data, and open files, but each thread has its own program counter, registers, and stack.

  • A single-threaded process has one execution path. If that thread waits for I/O, the process may appear blocked.
  • A multithreaded process has multiple execution paths—for example, a browser may use separate threads for the user interface, network requests, rendering, and downloads.

Benefits of multithreading

  1. Responsiveness: one thread can continue while another waits.
  2. Resource sharing: threads share the process’s memory and files.
  3. Economy: creating and switching threads is usually cheaper than creating processes.
  4. Scalability: threads can use multiple CPU cores.
  5. Parallelism: multiple threads can execute at the same time on a multicore processor.

User-level and kernel-level threads

PointUser-level threadsKernel-level threads
Managed byThread library in user spaceOS kernel
Creation and switchingFast, low overheadUsually more overhead because the kernel is involved
Kernel awarenessLimited or noneKernel knows and schedules each thread
BlockingIn some models, one blocking system call can block the whole processIf one thread blocks, other threads may continue
Multicore supportDepends on the implementationGood support for multicore scheduling

Thread-mapping models

1. Many-to-One model

Many user threads are mapped to one kernel thread.

flowchart LR
    subgraph U[User level]
        U1[U1]
        U2[U2]
        U3[U3]
    end
    subgraph K[Kernel level]
        K1[K1]
    end
    U1 --> K1
    U2 --> K1
    U3 --> K1
  • Advantages: simple implementation, fast management, low overhead.
  • Disadvantages: one blocking system call can block the process; there is no true parallel execution on multiple CPU cores.

2. One-to-One model

Each user thread is mapped to a separate kernel thread.

flowchart LR
    subgraph U[User level]
        U1[U1]
        U2[U2]
        U3[U3]
    end
    subgraph K[Kernel level]
        K1[K1]
        K2[K2]
        K3[K3]
    end
    U1 --> K1
    U2 --> K2
    U3 --> K3
  • Advantages: better concurrency, blocking one thread does not stop the others, and it can use multiple cores.
  • Disadvantages: creating many kernel threads adds overhead and the OS must manage every thread.

3. Many-to-Many model

Many user threads are multiplexed over a smaller or equal number of kernel threads.

flowchart LR
    subgraph U[User level]
        U1[U1]
        U2[U2]
        U3[U3]
        U4[U4]
    end
    subgraph K[Kernel level]
        K1[K1]
        K2[K2]
    end
    U1 --> K1
    U2 --> K1
    U2 --> K2
    U3 --> K2
    U4 --> K1
    U4 --> K2
  • Advantages: supports many user threads, provides flexibility, and allows parallelism without creating a kernel thread for every user thread.
  • Disadvantage: more complex to implement and manage.
  • fork() and exec() semantics: after fork() in a multithreaded process, the child may contain all threads or only the calling thread, depending on the OS semantics. exec() replaces the process image with another program.
  • Signal handling: the OS must decide which thread receives or handles a signal.
  • Thread cancellation: asynchronous cancellation stops immediately; deferred cancellation waits for a safe point and allows cleanup.
  • Thread pool: reuses a set of worker threads, reducing repeated creation overhead and controlling the number of threads.
  • Thread-local storage (TLS): gives each thread a private copy of selected data.
  • Scheduler activations: provide communication between a user-level thread library and the kernel about blocking, unblocking, and processor availability.

16. OS as a Resource Manager and an Extended Machine

A. OS as a resource manager

The OS controls and allocates limited resources among competing programs.

ResourceOS management
CPUScheduling, priorities, time slices, and context switches
Main memoryAllocation, deallocation, protection, and virtual memory
StorageFiles, directories, free-space management, and disk allocation
I/O devicesDrivers, buffering, queues, and device sharing
NetworkSockets, bandwidth use, routing support, and permissions
SecurityAuthentication and authorization for resources

The aim is efficient utilization, fairness, protection, and good response time.

B. OS as an extended machine

Hardware is complicated and differs between manufacturers. The OS hides these details and presents simple abstractions:

  • a file instead of raw disk sectors;
  • a process/thread instead of manually controlling CPU registers;
  • a standard device interface instead of device-specific electrical commands;
  • virtual memory instead of requiring a program to manage physical RAM addresses;
  • system calls, APIs, and GUI/CLI instead of direct hardware instructions.

Thus, the OS extends the basic hardware machine into a more convenient and safer machine for users and programs.

Real-world example: watching YouTube while downloading a file

  1. The OS creates and schedules a YouTube process and a download process.
  2. It allocates RAM for both and gives each process CPU time using scheduling and context switching.
  3. The browser uses a network socket for video and another connection for the download.
  4. The OS uses network buffers, writes the downloaded data to the file system, and sends video/audio data to the display and sound device through drivers.
  5. When either process waits for network or disk I/O, the OS runs another ready process instead of leaving the CPU idle.
  6. Permissions, error handling, memory protection, and battery/power policies keep the activities safe and efficient.

Here the OS is a resource manager because it shares CPU, RAM, disk, network, and devices. It is an extended machine because the browser uses files, sockets, drivers, and APIs rather than raw hardware commands.


17. Case study: Windows, Linux, and Android

Point of comparisonWindowsLinuxAndroid
1. Ownership and sourceProprietary OS developed by MicrosoftOpen-source kernel used in many distributionsOpen-source-based platform built around the Linux kernel; some Google/vendor components are proprietary
2. Main devices and useDesktops, laptops, enterprise systems, and gaming PCsServers, cloud systems, desktops, development systems, and embedded devicesSmartphones, tablets, TVs, cars, watches, and other mobile/embedded devices
3. User interface and ecosystemUser-friendly GUI, Windows applications, and broad commercial softwareChoice of desktop environments or command line; package managers and strong developer toolsTouch-first interface, widgets, notifications, and large mobile-app ecosystem
4. Security modelUser accounts, permissions, Defender, updates, and application securityPermissions, isolation, open review, distribution updates, and security tools such as SELinux in some systemsPer-app sandboxing and permissions, app signing, encryption, secure boot, and controlled background activity
5. Customization and resource profileModerate customization; broad hardware and software compatibility, but usually needs more resourcesVery high customization; stable and efficient, including on low-cost or specialized hardwareHigh device variety and customization by manufacturers; optimized for touch, battery, sensors, and mobile connectivity

Summary

  • Windows: general-purpose, commercial, desktop-oriented OS.
  • Linux: open, highly customizable OS strong in servers, programming, and embedded systems.
  • Android: mobile-oriented OS offering Linux foundations, touch interaction, and device/app integration.

18. Benefits for customers/users

Windows

  • Familiar GUI and easy setup for most users.
  • Wide compatibility with printers, accessories, games, and commercial software.
  • Large ecosystem for office work, education, business, and entertainment.
  • Strong hardware-driver and vendor support.
  • Good multitasking, accessibility, security tools, and regular updates.

Linux

  • Free and open source, with no compulsory license cost for most distributions.
  • Highly customizable desktops, tools, and system behavior.
  • Stable, secure, and suitable for servers and long-running workloads.
  • Works well on older or low-resource hardware.
  • Gives developers powerful command-line tools, compilers, package managers, and programming environments.
  • Provides users greater control, privacy, and the ability to inspect or modify the system.

Android

  • Available on a very wide range of devices and price points.
  • Touch-friendly interface with multitasking, notifications, widgets, and voice features.
  • Large application ecosystem and integration with maps, mail, photos, cloud storage, and media services.
  • Supports many hardware features: cameras, GPS, Bluetooth, NFC, sensors, and mobile data.
  • Offers device choice and manufacturer customization.
  • Includes app permissions, sandboxing, encryption, secure boot, and battery-management features.

One-minute revision

  • OS: interface + resource manager + protection system.
  • System call: program’s controlled request to the kernel.
  • System program: user-level utility that makes the OS convenient to use.
  • VM: software computer managed by a hypervisor.
  • Process: program in execution; its record is stored in a PCB.
  • Process states: New → Ready → Running → Waiting → Ready, or Running → Terminated.
  • Socket: network communication endpoint identified by IP and port.
  • RPC: call a procedure on another computer as if it were local.
  • Thread models: many-to-one, one-to-one, and many-to-many.

19. SJF and Gantt-chart numericals

What is FCFS?

FCFS means First Come, First Served. The process that arrives first gets the CPU first.

  • Follow the arrival order.
  • Run each process until it finishes.
  • FCFS is non-preemptive.
  • If processes arrive at the same time, follow the order given in the question.

Memory line: FCFS is like a queue at a ticket counter: first in, first out.

What is SJF?

SJF means Shortest Job First. The process with the smallest CPU time is selected first.

For the easy SJF method used below:

  • Check only the processes that have already arrived.
  • Select the process with the smallest Burst Time (BT).
  • Once a process starts, let it finish. This is non-preemptive SJF.
  • If two processes have the same BT, choose the one that arrived first.

Important terms

Short formFull formEasy meaning
ATArrival TimeWhen the process enters the system
BTBurst TimeCPU time needed by the process
CTCompletion TimeWhen the process finishes
TATTurnaround TimeTotal time from arrival to finish
WTWaiting TimeTime spent waiting for the CPU

Formulas to memorize

FormulaMemory sentence
TAT = CT - ATFinish time − arrival time
WT = TAT - BTTurnaround time − CPU time
Average WT = Total WT / nAdd all waiting times, then divide by number of processes
Average TAT = Total TAT / nAdd all turnaround times, then divide by number of processes

What is a Gantt chart?

A Gantt chart shows which process is using the CPU and for how long.

|  Process  |  Process  |
0          5          8
  • The numbers show time.
  • The name inside each block shows the running process.
  • The right-end number of a process is its CT.

Easy numerical 1: all processes arrive at time 0

Given

ProcessATBT
P106
P202
P304

Step 1: Arrange by shortest BT

P2 (2) → P3 (4) → P1 (6)

Step 2: Draw the Gantt chart

0       2           6                   12
|  P2   |    P3     |        P1         |

Step 3: Calculate the answers

ProcessATBTCTTAT = CT − ATWT = TAT − BT
P10612126
P202220
P304662
  • Average WT = (6 + 0 + 2) / 3 = 2.67 units
  • Average TAT = (12 + 2 + 6) / 3 = 6.67 units

Easy numerical 2: different arrival times

Given

ProcessATBT
P107
P224
P341

Step 1: Choose the process

Current timeProcesses availableChoiceReason
0P1P1Only P1 has arrived
7P2, P3P3P3 has the smaller BT
8P2P2Only P2 is left

Step 2: Draw the Gantt chart

0                       7       8                   12
|          P1           |  P3   |        P2         |

Step 3: Calculate the answers

ProcessATBTCTTAT = CT − ATWT = TAT − BT
P107770
P22412106
P341843
  • Average WT = (0 + 6 + 3) / 3 = 3 units
  • Average TAT = (7 + 10 + 4) / 3 = 7 units

SJF exam steps

  1. Write the AT and BT of every process.
  2. Start the clock at 0.
  3. Check which processes have arrived.
  4. Pick the one with the shortest BT.
  5. Draw a Gantt-chart block whose length equals its BT.
  6. Repeat until every process is finished.
  7. Read CT from the chart, then calculate TAT and WT.

Important: If the question says preemptive SJF or SRTF, a running process may be stopped when a shorter process arrives. If it only says SJF, use the non-preemptive method above.

Worked example from the question sheet: Problem 3

This question gives only burst times, so assume all processes arrive at time 0. Solve it using non-preemptive SJF.

Given

ProcessBurst Time (BT)
P16
P28
P37
P43

Step 1: Arrange from shortest BT to longest BT

P4 (3) → P1 (6) → P3 (7) → P2 (8)

Step 2: Draw the Gantt chart

0           3                   9                       16                              24
|    P4     |         P1        |           P3          |              P2              |

Step 3: Calculate the answers

ProcessATBTCTTAT = CT − ATWT = TAT − BT
P106993
P208242416
P30716169
P403330
  • Average WT = (3 + 16 + 9 + 0) / 4 = 7 units
  • Average TAT = (9 + 24 + 16 + 3) / 4 = 13 units

20. Round Robin numericals

What is Round Robin?

Round Robin (RR) gives every process a small, equal amount of CPU time in turn.

This small fixed amount of time is called the Time Quantum (TQ).

For the easy method:

  • Follow the queue order: first process, second process, third process, and so on.
  • Give each process at most one time quantum.
  • If a process finishes, remove it from the queue.
  • If it does not finish, put it at the end of the queue.
  • Repeat until the queue is empty.

Memory line: Round Robin means take a turn, go to the back, take another turn.

Easy numerical

Given

All processes arrive at time 0.

ProcessBurst Time (BT)
P15
P24
P32

Time Quantum (TQ) = 2 units

Step 1: Start with the queue

P1 → P2 → P3

Step 2: Give each process one turn

TimeProcess runningWork doneRemaining BTQueue after the turn
0–2P123P2 → P3 → P1
2–4P222P3 → P1 → P2
4–6P320P1 → P2
6–8P121P2 → P1
8–10P220P1
10–11P110Empty

Step 3: Draw the Gantt chart

0       2       4       6       8       10      11
|  P1   |  P2   |  P3   |  P1   |  P2   |  P1   |

Step 4: Find completion time

The right-end time of each process is its CT:

  • P3 finishes at 6, so CT of P3 = 6.
  • P2 finishes at 10, so CT of P2 = 10.
  • P1 finishes at 11, so CT of P1 = 11.

Step 5: Calculate TAT and WT

Since every process arrives at 0:

  • TAT = CT − AT
  • WT = TAT − BT
ProcessATBTCTTAT = CT − ATWT = TAT − BT
P10511116
P20410106
P302664
  • Average WT = (6 + 6 + 4) / 3 = 5.33 units
  • Average TAT = (11 + 10 + 6) / 3 = 9 units

Round Robin exam steps

  1. Write the processes in their starting queue order.
  2. Write the Time Quantum (TQ).
  3. Run the first process for TQ units or until it finishes.
  4. Move unfinished processes to the back of the queue.
  5. Continue until all processes finish.
  6. Draw the Gantt chart.
  7. Read CT, then calculate TAT and WT.

SJF versus Round Robin

PointSJFRound Robin
Main ruleShortest BT runs firstEveryone gets a turn
Important valueBurst Time (BT)Time Quantum (TQ)
Process can be stopped?No, in basic SJFYes, after each time quantum