๐ง 1. Introduction to Operating System
๐น What is an Operating System (OS)?
An Operating System is system software that acts as an interface between the user and the computer hardware.
It manages hardware, software, files, memory, and processes.
Example: Windows, Linux, macOS, Android, UNIX.
๐น Functions of Operating System
| Function | Description |
|---|---|
| Process Management | Manages processes (creation, scheduling, termination). |
| Memory Management | Allocates and deallocates memory. |
| File Management | Manages data storage, access, and retrieval. |
| Device Management | Controls I/O devices through drivers. |
| Security & Protection | Prevents unauthorized access. |
| User Interface | Provides CLI (Command Line) or GUI (Graphical User Interface). |
| Error Detection | Monitors and handles system errors. |
โ๏ธ 2. Types of Operating Systems
| Type | Description | Examples |
|---|---|---|
| Batch OS | Jobs executed in batches without user interaction. | Early IBM OS |
| Multiprogramming OS | Runs multiple programs at once. | UNIX |
| Multitasking OS | Executes multiple tasks simultaneously. | Windows, macOS |
| Time-Sharing OS | Multiple users access system simultaneously. | Linux, UNIX |
| Distributed OS | Runs on multiple connected systems (networked). | LOCUS, Amoeba |
| Real-Time OS (RTOS) | Responds instantly to input. | VxWorks, QNX |
| Embedded OS | Built into devices for specific functions. | Android Auto, IoT OS |
| Mobile OS | Designed for smartphones & tablets. | Android, iOS |
๐ฉโ๐ป 3. OS Structure and Components
๐น A. Kernel
The core part of the OS โ controls all system operations.
| Type | Description |
|---|---|
| Monolithic Kernel | All services run in kernel mode (fast but less secure). |
| Microkernel | Only essential services in kernel; others in user mode (more secure). |
| Hybrid Kernel | Mix of both approaches (used in Windows, macOS). |
๐น B. Shell
Interface between user and OS kernel.
- CLI (Command Line Interface):ย e.g., MS-DOS, Bash.
- GUI (Graphical User Interface):ย e.g., Windows, GNOME.
๐น C. System Calls
Functions that allow user programs to request services from the OS kernel.
Example: fork(), open(), read(), write() in UNIX.
๐ 4. Process Management
๐น Definition
A process is a program in execution.
๐น Process States
- Newย โ Process created
- Readyย โ Waiting for CPU
- Runningย โ Under execution
- Waiting/Blockedย โ Waiting for I/O
- Terminatedย โ Completed
๐น Process Control Block (PCB)
A data structure that stores process information.
Contains:
- Process ID (PID)
- Process state
- CPU registers
- Program counter
- Memory limits
๐น Context Switching
Process of saving the state of a CPU from one process and loading it for another.
๐น Process Scheduling
Determines which process runs next.
Types of Schedulers:
| Type | Function |
|---|---|
| Long-term | Admits processes into the system. |
| Short-term | Chooses process for CPU. |
| Medium-term | Suspends/resumes processes. |
๐น Scheduling Algorithms
| Algorithm | Description | Criteria |
|---|---|---|
| FCFS (First Come First Serve) | Executes processes in arrival order. | Simple but may cause convoy effect. |
| SJF (Shortest Job First) | Shortest burst time process first. | Minimizes waiting time. |
| RR (Round Robin) | Each process gets fixed time slice (quantum). | Good for time-sharing systems. |
| Priority Scheduling | Highest priority process runs first. | Can cause starvation. |
| Multilevel Queue | Multiple queues with different priorities. | Used in advanced systems. |
๐งฎ 5. Threads
A thread is a lightweight process โ the smallest unit of CPU execution.
- Single-threaded:ย One thread per process.
- Multi-threaded:ย Multiple threads share same code & data.
Advantages:
- Faster execution
- Resource sharing
- Better performance on multicore CPUs
๐พ 6. Memory Management
๐น Goal
Efficient allocation and protection of main memory (RAM).
๐น Memory Allocation Methods
| Method | Description |
|---|---|
| Contiguous Allocation | Processes occupy continuous memory blocks. |
| Non-Contiguous Allocation | Memory divided into partitions (paging, segmentation). |
๐น Paging
- Divides memory into fixed-sizeย pagesย andย frames.
- Logical memory (pages) mapped to physical memory (frames).
- Avoids fragmentation.
๐น Segmentation
- Divides memory into variable-sizeย segmentsย based on program logic.
- Each segment has name, size, and address.
๐น Virtual Memory
Technique to use hard disk space as temporary RAM (swap space).
Implemented using: Paging or Segmentation.
Example: When RAM is full, inactive data moved to swap file.
๐น Fragmentation
| Type | Description |
|---|---|
| Internal Fragmentation | Unused space within allocated memory. |
| External Fragmentation | Free memory scattered in small blocks. |
Solution: Compaction or Paging.
๐ง 7. Deadlocks
๐น Definition
A deadlock occurs when two or more processes wait indefinitely for each otherโs resources.
๐น Necessary Conditions (Coffmanโs Conditions)
- Mutual Exclusion
- Hold and Wait
- No Preemption
- Circular Wait
๐น Deadlock Handling
| Method | Description |
|---|---|
| Prevention | Eliminate one of the four conditions. |
| Avoidance | Use algorithms like Bankerโs Algorithm. |
| Detection & Recovery | Detect deadlock and terminate processes. |
๐ 8. File Management
๐น Concept
A file is a collection of data stored on disk. OS manages files using directories and permissions.
๐น Operations on Files
- Create
- Open
- Read
- Write
- Close
- Delete
๐น File Access Methods
| Method | Description |
|---|---|
| Sequential Access | Read data in order. |
| Direct Access (Random) | Access any part directly. |
| Indexed Access | Uses an index to access data quickly. |
๐น Directory Structures
| Structure | Description |
|---|---|
| Single-level | One directory for all files. |
| Two-level | Separate directory for each user. |
| Tree-structured | Hierarchical directories. |
| Acyclic Graph | Shared subdirectories allowed. |
๐ฟ 9. Input/Output (I/O) Management
๐น Purpose
Manage communication between CPU and peripheral devices.
๐น I/O Techniques
| Type | Description |
|---|---|
| Programmed I/O | CPU handles all I/O tasks. |
| Interrupt-Driven I/O | Devices notify CPU when ready. |
| DMA (Direct Memory Access) | Data transferred directly between I/O and memory (fastest). |
๐ 10. Security & Protection
๐น Goals
- Protect data and resources from unauthorized access.
๐น Mechanisms
| Mechanism | Description |
|---|---|
| Authentication | Verifying identity (username/password). |
| Authorization | Assigning access rights. |
| Encryption | Data protection using cryptography. |
| Access Control List (ACL) | Permissions for files and devices. |
๐งฎ 11. System Performance and Utilities
๐น System Performance Metrics
- CPU Utilization
- Throughput (jobs/sec)
- Turnaround Time
- Response Time
- Waiting Time
๐น System Utilities
Small programs that perform maintenance tasks.
Examples: Disk cleanup, Task manager, Backup tools.
๐งฑ 12. Operating System Interfaces
| Interface | Description | Example |
|---|---|---|
| CLI (Command Line) | Text-based interface | UNIX shell |
| GUI (Graphical) | Visual interface with icons/windows | Windows OS |
| API | For application developers | WinAPI, POSIX |
๐งฉ 13. Common Operating Systems
| OS | Type | Features |
|---|---|---|
| Windows | GUI, multitasking | User-friendly, commercial |
| Linux/UNIX | Open-source, multitasking | Secure, stable |
| macOS | GUI-based, UNIX core | For Apple devices |
| Android | Mobile OS | Linux-based, open-source |
| iOS | Mobile OS | For Apple devices only |
๐ 14. Booting Process
๐น Steps in Booting:
- Power On
- POST (Power-On Self-Test)
- Load Bootloader (BIOS/UEFI)
- Load OS kernel
- Start system services & login
๐งฎ 15. Virtualization and Cloud OS
| Concept | Description |
|---|---|
| Virtualization | Running multiple OS on one machine using hypervisor. |
| Hypervisor | Software that manages virtual machines (e.g., VMware, VirtualBox). |
| Cloud OS | Manages cloud-based resources (e.g., AWS, Azure). |
โก 16. Common OS Commands
| OS | Command | Purpose |
|---|---|---|
| Windows | dir, copy, del, tasklist | File and task management |
| Linux/UNIX | ls, cp, rm, ps, chmod | File and process management |
| macOS | Similar to UNIX commands | Terminal-based management |
๐ 17. Summary Table
| Topic | Key Point |
|---|---|
| OS | Interface between user & hardware |
| Kernel | Core of OS |
| Process | Program in execution |
| Scheduling | Decides execution order |
| Memory Mgmt | Allocates RAM effectively |
| File Mgmt | Manages storage structure |
| Deadlock | Resource waiting cycle |
| Security | Protects data |
| Virtual Memory | Uses disk as RAM |
| Virtualization | Multiple OS on one machine |
