Operating System

๐Ÿง  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

FunctionDescription
Process ManagementManages processes (creation, scheduling, termination).
Memory ManagementAllocates and deallocates memory.
File ManagementManages data storage, access, and retrieval.
Device ManagementControls I/O devices through drivers.
Security & ProtectionPrevents unauthorized access.
User InterfaceProvides CLI (Command Line) or GUI (Graphical User Interface).
Error DetectionMonitors and handles system errors.

โš™๏ธ 2. Types of Operating Systems

TypeDescriptionExamples
Batch OSJobs executed in batches without user interaction.Early IBM OS
Multiprogramming OSRuns multiple programs at once.UNIX
Multitasking OSExecutes multiple tasks simultaneously.Windows, macOS
Time-Sharing OSMultiple users access system simultaneously.Linux, UNIX
Distributed OSRuns on multiple connected systems (networked).LOCUS, Amoeba
Real-Time OS (RTOS)Responds instantly to input.VxWorks, QNX
Embedded OSBuilt into devices for specific functions.Android Auto, IoT OS
Mobile OSDesigned for smartphones & tablets.Android, iOS

๐Ÿ‘ฉโ€๐Ÿ’ป 3. OS Structure and Components

๐Ÿ”น A. Kernel

The core part of the OS โ€” controls all system operations.

TypeDescription
Monolithic KernelAll services run in kernel mode (fast but less secure).
MicrokernelOnly essential services in kernel; others in user mode (more secure).
Hybrid KernelMix 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

process is a program in execution.

๐Ÿ”น Process States

  1. Newย โ€“ Process created
  2. Readyย โ€“ Waiting for CPU
  3. Runningย โ€“ Under execution
  4. Waiting/Blockedย โ€“ Waiting for I/O
  5. 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:

TypeFunction
Long-termAdmits processes into the system.
Short-termChooses process for CPU.
Medium-termSuspends/resumes processes.

๐Ÿ”น Scheduling Algorithms

AlgorithmDescriptionCriteria
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 SchedulingHighest priority process runs first.Can cause starvation.
Multilevel QueueMultiple queues with different priorities.Used in advanced systems.

๐Ÿงฎ 5. Threads

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

MethodDescription
Contiguous AllocationProcesses occupy continuous memory blocks.
Non-Contiguous AllocationMemory 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

TypeDescription
Internal FragmentationUnused space within allocated memory.
External FragmentationFree memory scattered in small blocks.

Solution: Compaction or Paging.


๐Ÿง  7. Deadlocks

๐Ÿ”น Definition

deadlock occurs when two or more processes wait indefinitely for each otherโ€™s resources.

๐Ÿ”น Necessary Conditions (Coffmanโ€™s Conditions)

  1. Mutual Exclusion
  2. Hold and Wait
  3. No Preemption
  4. Circular Wait

๐Ÿ”น Deadlock Handling

MethodDescription
PreventionEliminate one of the four conditions.
AvoidanceUse algorithms like Bankerโ€™s Algorithm.
Detection & RecoveryDetect deadlock and terminate processes.

๐Ÿ“‚ 8. File Management

๐Ÿ”น Concept

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

MethodDescription
Sequential AccessRead data in order.
Direct Access (Random)Access any part directly.
Indexed AccessUses an index to access data quickly.

๐Ÿ”น Directory Structures

StructureDescription
Single-levelOne directory for all files.
Two-levelSeparate directory for each user.
Tree-structuredHierarchical directories.
Acyclic GraphShared subdirectories allowed.

๐Ÿ’ฟ 9. Input/Output (I/O) Management

๐Ÿ”น Purpose

Manage communication between CPU and peripheral devices.

๐Ÿ”น I/O Techniques

TypeDescription
Programmed I/OCPU handles all I/O tasks.
Interrupt-Driven I/ODevices 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

MechanismDescription
AuthenticationVerifying identity (username/password).
AuthorizationAssigning access rights.
EncryptionData 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

InterfaceDescriptionExample
CLI (Command Line)Text-based interfaceUNIX shell
GUI (Graphical)Visual interface with icons/windowsWindows OS
APIFor application developersWinAPI, POSIX

๐Ÿงฉ 13. Common Operating Systems

OSTypeFeatures
WindowsGUI, multitaskingUser-friendly, commercial
Linux/UNIXOpen-source, multitaskingSecure, stable
macOSGUI-based, UNIX coreFor Apple devices
AndroidMobile OSLinux-based, open-source
iOSMobile OSFor Apple devices only

๐Ÿš€ 14. Booting Process

๐Ÿ”น Steps in Booting:

  1. Power On
  2. POST (Power-On Self-Test)
  3. Load Bootloader (BIOS/UEFI)
  4. Load OS kernel
  5. Start system services & login

๐Ÿงฎ 15. Virtualization and Cloud OS

ConceptDescription
VirtualizationRunning multiple OS on one machine using hypervisor.
HypervisorSoftware that manages virtual machines (e.g., VMware, VirtualBox).
Cloud OSManages cloud-based resources (e.g., AWS, Azure).

โšก 16. Common OS Commands

OSCommandPurpose
WindowsdircopydeltasklistFile and task management
Linux/UNIXlscprmpschmodFile and process management
macOSSimilar to UNIX commandsTerminal-based management

๐Ÿ 17. Summary Table

TopicKey Point
OSInterface between user & hardware
KernelCore of OS
ProcessProgram in execution
SchedulingDecides execution order
Memory MgmtAllocates RAM effectively
File MgmtManages storage structure
DeadlockResource waiting cycle
SecurityProtects data
Virtual MemoryUses disk as RAM
VirtualizationMultiple OS on one machine

Leave a Comment

Your email address will not be published. Required fields are marked *