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
- Process management: Creates and terminates processes, schedules CPU time, performs context switching, and coordinates processes.
- Memory management: Keeps track of memory usage, allocates and deallocates RAM, and prevents one process from corrupting another process’s memory.
- File management: Creates, names, stores, opens, reads, writes, copies, moves, and deletes files and directories. It also manages file permissions.
- 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.
- Secondary-storage management: Organizes free space and allocates disk space for files and programs.
- Protection and security: Authenticates users, enforces access permissions, protects data, and supports encryption and secure access.
- User interface: Provides a GUI (windows, icons, menus), CLI (commands), or touch interface.
- Communication and networking: Allows processes and computers to exchange data using pipes, shared memory, sockets, and network services.
- Error detection and handling: Detects CPU, memory, I/O, file, and application errors and takes corrective action.
- 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
| Year | Stage |
|---|---|
| 1940 | First Generation |
| 1955 | Second Generation |
| 1965 | Third Generation |
| 1980 | Fourth Generation |
| 1990 | Modern Operating Systems |
| Today | Modern Operating Systems |
First Generation (1940–1955)
| Item | Easy pointer |
|---|---|
| Operating system | No operating system |
| Features | Vacuum tubes Machine language Manual programming No GUI |
| Problems | Slow Difficult One program only |
Second Generation (about 1955–1965)
| Item | Easy pointer |
|---|---|
| Operating system | Batch operating system |
| Definition | Users submitted jobs using punch cards. Computer executed all jobs automatically. |
| Advantages | Better CPU utilization Reduced setup time |
| Disadvantage | No interaction |
| Example | Electricity bill generation |
Third Generation (about 1965–1980)
| Item | Easy pointer |
|---|---|
| Technology | Multiprogramming |
| Features | Multiple jobs stored in RAM CPU switches rapidly Better performance |
| Advantages | High CPU utilization Reduced waiting time |
| Time-sharing OS | Many users use one computer simultaneously |
| Examples | University Labs Banking |
How multiprogramming works
| Step | Easy pointer |
|---|---|
| 1 | Multiple programs are loaded into the main memory (RAM). |
| 2 | The CPU executes one program for a short interval. |
| 3 | When that program waits for input/output (I/O), the CPU switches to another program. |
| 4 | This keeps the CPU busy and improves overall system performance. |
Everyday analogy
| Step | Chef analogy |
|---|---|
| 1 | The chef starts cooking rice. |
| 2 | While the rice is boiling, the chef prepares vegetables. |
| 3 | While the vegetables are cooking, the chef makes chapati. |
| 4 | While the chapati is on the pan, the chef prepares dessert. |
Fourth Generation (1980 onward)
| Item | Easy pointer |
|---|---|
| Operating system | GUI operating systems |
| Examples | Windows macOS Linux |
| Features | Mouse Icons Windows Networking |
Modern Operating Systems (1990s–Today)
| Item | Easy pointer |
|---|---|
| Examples | Android iOS ChromeOS Embedded Linux IoT OS |
| Applications | Smartphones Cars Smart TVs Smart Watches |
Evolution summary table
| Generation | Technology | Example |
|---|---|---|
| 1 | No OS | ENIAC |
| 2 | Batch | IBM |
| 3 | Multiprogramming | UNIX |
| 4 | GUI | Windows |
| 5 | Cloud | Android |
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
| Letter | Structure |
|---|---|
| S | Simple |
| L | Layered |
| M | Microkernel |
| M | Modular |
| H | Hybrid |
Ratings in ascending order
Low → Medium → High → Very High
| Structure | Relative speed | Security / isolation | Flexibility |
|---|---|---|---|
| Layered | Medium | High | Medium |
| Microkernel | Medium | Very High | High |
| Simple | High | Low | Low |
| Modular | High | High | High |
| Hybrid | Very High | High | High |
4. Services provided by an OS to users and programs
| Service | What the OS does | Example |
|---|---|---|
| User interface | Accepts commands, clicks, or touch input and displays output | Windows GUI, Linux terminal, Android touch screen |
| Program execution | Loads a program, allocates required memory, starts it, and terminates it | Opening Microsoft Word or Chrome |
| I/O operations | Provides a controlled way for programs to use input/output devices | Reading the keyboard or printing a document |
| File-system manipulation | Creates, deletes, opens, closes, reads, writes, renames, copies, and moves files; applies permissions | Saving a file in Google Drive or Windows Explorer |
| Communication | Allows processes on the same computer or different computers to exchange data | Pipes, shared memory, sockets, messaging |
| Error detection | Detects and reports hardware, memory, disk, I/O, and program errors | Reporting a disk-read error |
| Resource allocation | Decides which process receives CPU, RAM, storage, network, or a device | Playing YouTube while downloading a file |
| Protection and security | Authenticates users and controls access to programs, memory, files, and devices | Password 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
| Type | Purpose | Common examples |
|---|---|---|
| Process control | Create, execute, wait for, suspend, resume, and terminate processes | fork(), exec(), wait(), exit() |
| File management | Create, open, close, read, write, and delete files | open(), read(), write(), close(), unlink() |
| Device management | Request/release a device and read from or write to it | Device I/O requests, printer and keyboard operations |
| Information maintenance | Get or set time, date, system data, process ID, and accounting information | getpid(), time() |
| Communication | Exchange messages, use pipes, shared memory, or sockets | pipe(), shared-memory calls, send()/recv() |
| Protection / security | Authenticate users and manage permissions and protected resources | chmod(), 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.
| Category | Purpose | Examples |
|---|---|---|
| File-management programs | Copy, move, rename, delete, and organize files | Windows File Explorer, Linux file manager |
| Status-information programs | Display date, time, CPU, memory, disk, and process usage | Windows Task Manager, Linux System Monitor |
| File-modification programs | Create and edit text or documents | Notepad, Microsoft Word, VS Code |
| Programming-language support | Compile, interpret, assemble, and debug programs | GCC, javac, Python interpreter |
| Program loading and execution | Load executable files and start applications | Shell, program loader, double-clicking Chrome |
| Communication programs | Support communication over networks | Chrome, Outlook, Zoom, Microsoft Teams |
| Background services / daemons | Run continuously and perform system tasks | Windows Update, antivirus service, print spooler, Bluetooth service |
System calls versus system programs
| System calls | System programs |
|---|---|
| Low-level interface between an application and the kernel | Higher-level utilities used by users or administrators |
| Usually entered through a controlled kernel-mode transition | Normally 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 OS | Developer / organization | Main description |
|---|---|---|
| Android | Google / Open Handset Alliance | Open-source-based, widely used on phones, tablets, TVs, and other devices; has the Google Play ecosystem |
| iOS | Apple | Closed-source mobile OS used on iPhones; tightly integrated with Apple hardware and services |
| HarmonyOS | Huawei | Distributed OS for phones, wearables, and IoT devices |
| KaiOS | KaiOS Technologies | Lightweight OS used mainly in feature phones |
| Tizen | Samsung and partners | Used 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
- Process management: Manages running apps, supports multitasking, and controls background activity.
- Memory management: Allocates RAM to apps, frees unused memory, and prevents apps from interfering with one another.
- File management: Organizes files and folders and provides secure internal or removable storage.
- Device management: Controls the camera, microphone, display, speakers, Bluetooth, sensors, GPS, Wi-Fi, NFC, and USB through drivers and interfaces.
- Security management: Provides login/authentication, app sandboxing and permissions, encryption, secure boot, and app verification.
- Network management: Manages Wi-Fi, mobile data, Bluetooth, hotspot, VPN, and handover between networks.
- Power management: Optimizes battery use, controls sleep mode and background work, and supports charging features.
- User interaction: Provides touchscreen, multi-touch gestures, notifications, widgets, voice assistants, and accessibility tools.
- 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.
| Program | Process |
|---|---|
| Passive set of instructions | Active program currently executing |
| Stored on secondary storage | Loaded into main memory for execution |
| Static and does not have a state | Dynamic and moves through states such as ready, running, and waiting |
| Does not need the CPU while inactive | Needs CPU time during execution |
Example: chrome.exe stored on disk | A 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 field | Meaning |
|---|---|
| Process ID (PID) | Unique identification number |
| Process state | New, ready, running, waiting, or terminated |
| Program counter | Address of the next instruction |
| CPU registers | Saved CPU values when the process is not running |
| CPU-scheduling information | Priority, queue pointers, and time-slice information |
| Memory-management information | Base/limit, page-table, or other memory details |
| I/O status information | Open files and allocated devices |
| Accounting information | CPU 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
| Transition | Meaning |
|---|---|
| New → Ready | Process is admitted |
| Ready → Running | CPU scheduler dispatches it |
| Running → Waiting / Blocked | It waits for I/O or an event |
| Waiting / Blocked → Ready | I/O or event completes |
| Running → Ready | Interrupt or time slice expires |
| Running → Terminated | Exit, 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
- The client calls a local-looking function.
- The client stub marshals (packs) the arguments into a message.
- The message travels through the network.
- The server stub unmarshals the arguments and calls the server procedure.
- 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
| Point | Socket | RPC |
|---|---|---|
| Abstraction | Low-level communication endpoint | High-level remote function call |
| Programmer manages | Connections, messages, bytes, and protocol | Function interface and arguments; framework handles much of the messaging |
| Typical use | Web, chat, streaming, custom network protocols | Distributed applications and service APIs |
| Example | Browser sends an HTTP request through TCP | Banking 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
- Responsiveness: one thread can continue while another waits.
- Resource sharing: threads share the process’s memory and files.
- Economy: creating and switching threads is usually cheaper than creating processes.
- Scalability: threads can use multiple CPU cores.
- Parallelism: multiple threads can execute at the same time on a multicore processor.
User-level and kernel-level threads
| Point | User-level threads | Kernel-level threads |
|---|---|---|
| Managed by | Thread library in user space | OS kernel |
| Creation and switching | Fast, low overhead | Usually more overhead because the kernel is involved |
| Kernel awareness | Limited or none | Kernel knows and schedules each thread |
| Blocking | In some models, one blocking system call can block the whole process | If one thread blocks, other threads may continue |
| Multicore support | Depends on the implementation | Good 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.
Related threading issues
fork()andexec()semantics: afterfork()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.
| Resource | OS management |
|---|---|
| CPU | Scheduling, priorities, time slices, and context switches |
| Main memory | Allocation, deallocation, protection, and virtual memory |
| Storage | Files, directories, free-space management, and disk allocation |
| I/O devices | Drivers, buffering, queues, and device sharing |
| Network | Sockets, bandwidth use, routing support, and permissions |
| Security | Authentication 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
- The OS creates and schedules a YouTube process and a download process.
- It allocates RAM for both and gives each process CPU time using scheduling and context switching.
- The browser uses a network socket for video and another connection for the download.
- 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.
- When either process waits for network or disk I/O, the OS runs another ready process instead of leaving the CPU idle.
- 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 comparison | Windows | Linux | Android |
|---|---|---|---|
| 1. Ownership and source | Proprietary OS developed by Microsoft | Open-source kernel used in many distributions | Open-source-based platform built around the Linux kernel; some Google/vendor components are proprietary |
| 2. Main devices and use | Desktops, laptops, enterprise systems, and gaming PCs | Servers, cloud systems, desktops, development systems, and embedded devices | Smartphones, tablets, TVs, cars, watches, and other mobile/embedded devices |
| 3. User interface and ecosystem | User-friendly GUI, Windows applications, and broad commercial software | Choice of desktop environments or command line; package managers and strong developer tools | Touch-first interface, widgets, notifications, and large mobile-app ecosystem |
| 4. Security model | User accounts, permissions, Defender, updates, and application security | Permissions, isolation, open review, distribution updates, and security tools such as SELinux in some systems | Per-app sandboxing and permissions, app signing, encryption, secure boot, and controlled background activity |
| 5. Customization and resource profile | Moderate customization; broad hardware and software compatibility, but usually needs more resources | Very high customization; stable and efficient, including on low-cost or specialized hardware | High 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 form | Full form | Easy meaning |
|---|---|---|
| AT | Arrival Time | When the process enters the system |
| BT | Burst Time | CPU time needed by the process |
| CT | Completion Time | When the process finishes |
| TAT | Turnaround Time | Total time from arrival to finish |
| WT | Waiting Time | Time spent waiting for the CPU |
Formulas to memorize
| Formula | Memory sentence |
|---|---|
TAT = CT - AT | Finish time − arrival time |
WT = TAT - BT | Turnaround time − CPU time |
Average WT = Total WT / n | Add all waiting times, then divide by number of processes |
Average TAT = Total TAT / n | Add 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
| Process | AT | BT |
|---|---|---|
| P1 | 0 | 6 |
| P2 | 0 | 2 |
| P3 | 0 | 4 |
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
| Process | AT | BT | CT | TAT = CT − AT | WT = TAT − BT |
|---|---|---|---|---|---|
| P1 | 0 | 6 | 12 | 12 | 6 |
| P2 | 0 | 2 | 2 | 2 | 0 |
| P3 | 0 | 4 | 6 | 6 | 2 |
- 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
| Process | AT | BT |
|---|---|---|
| P1 | 0 | 7 |
| P2 | 2 | 4 |
| P3 | 4 | 1 |
Step 1: Choose the process
| Current time | Processes available | Choice | Reason |
|---|---|---|---|
| 0 | P1 | P1 | Only P1 has arrived |
| 7 | P2, P3 | P3 | P3 has the smaller BT |
| 8 | P2 | P2 | Only P2 is left |
Step 2: Draw the Gantt chart
0 7 8 12
| P1 | P3 | P2 |Step 3: Calculate the answers
| Process | AT | BT | CT | TAT = CT − AT | WT = TAT − BT |
|---|---|---|---|---|---|
| P1 | 0 | 7 | 7 | 7 | 0 |
| P2 | 2 | 4 | 12 | 10 | 6 |
| P3 | 4 | 1 | 8 | 4 | 3 |
- Average WT =
(0 + 6 + 3) / 3 = 3 units - Average TAT =
(7 + 10 + 4) / 3 = 7 units
SJF exam steps
- Write the AT and BT of every process.
- Start the clock at
0. - Check which processes have arrived.
- Pick the one with the shortest BT.
- Draw a Gantt-chart block whose length equals its BT.
- Repeat until every process is finished.
- 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
| Process | Burst Time (BT) |
|---|---|
| P1 | 6 |
| P2 | 8 |
| P3 | 7 |
| P4 | 3 |
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
| Process | AT | BT | CT | TAT = CT − AT | WT = TAT − BT |
|---|---|---|---|---|---|
| P1 | 0 | 6 | 9 | 9 | 3 |
| P2 | 0 | 8 | 24 | 24 | 16 |
| P3 | 0 | 7 | 16 | 16 | 9 |
| P4 | 0 | 3 | 3 | 3 | 0 |
- 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.
| Process | Burst Time (BT) |
|---|---|
| P1 | 5 |
| P2 | 4 |
| P3 | 2 |
Time Quantum (TQ) = 2 units
Step 1: Start with the queue
P1 → P2 → P3
Step 2: Give each process one turn
| Time | Process running | Work done | Remaining BT | Queue after the turn |
|---|---|---|---|---|
| 0–2 | P1 | 2 | 3 | P2 → P3 → P1 |
| 2–4 | P2 | 2 | 2 | P3 → P1 → P2 |
| 4–6 | P3 | 2 | 0 | P1 → P2 |
| 6–8 | P1 | 2 | 1 | P2 → P1 |
| 8–10 | P2 | 2 | 0 | P1 |
| 10–11 | P1 | 1 | 0 | Empty |
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 − ATWT = TAT − BT
| Process | AT | BT | CT | TAT = CT − AT | WT = TAT − BT |
|---|---|---|---|---|---|
| P1 | 0 | 5 | 11 | 11 | 6 |
| P2 | 0 | 4 | 10 | 10 | 6 |
| P3 | 0 | 2 | 6 | 6 | 4 |
- Average WT =
(6 + 6 + 4) / 3 = 5.33 units - Average TAT =
(11 + 10 + 6) / 3 = 9 units
Round Robin exam steps
- Write the processes in their starting queue order.
- Write the Time Quantum (TQ).
- Run the first process for
TQunits or until it finishes. - Move unfinished processes to the back of the queue.
- Continue until all processes finish.
- Draw the Gantt chart.
- Read CT, then calculate TAT and WT.
SJF versus Round Robin
| Point | SJF | Round Robin |
|---|---|---|
| Main rule | Shortest BT runs first | Everyone gets a turn |
| Important value | Burst Time (BT) | Time Quantum (TQ) |
| Process can be stopped? | No, in basic SJF | Yes, after each time quantum |