Operating System
OS Part-1
OS Part-2
- File Concepts and Access methods
- Free Space Management and Allocation methods
- Directory Systems and Protection
- File Organization, Sharing and Implementation issues
- Disk and Drum Scheduling
- I/O Devices Organisation & I/O Buffering
- I/O Hardware, Kernel I/O subsystem and Transforming I/O Requests to Hardware Operations
- Device Drivers and Path Management
- Device Driver Sub Modules and Procedure
- Device Scheduler and Handler
- Interrupt Service Routine (ISR)
- File System in Linux and Windows
OS Part-3
- Process and Process Control Block(PCB)
- Process Scheduling( Preemptive and Non Preemptive)
- Scheduling Algorithms
- Algorithm Evaluation
- Multiple Processor Scheduling
- Real Time Scheduling
- Operations on Processes
- Threads
- Inter-Process Communication
- Precedence Graphs
- Critical Section Problem
- Semaphores
- Classical Problems of Synchronization
- DeadLock
- Deadlock Prevention and Avoidance
- Deadlock Detection and Recovery
- Process Management in Linux
OS Part-4
- Memory Hierarchy in OS
- Concepts of Memory Management
- MFT and MVT
- Logical and Physical Address Space
- Swapping
- Contiguous and Non Contiguous Memory Allocation
- Paging
- Segmentation
- Paging Combined with Segmentation
- Structure and Implementation of Page Table
- Virtual Memory in OS
- Cache Memory Organization
- Demand Paging
- Page Replacement Algorithms
- Allocation of Frames and Thrashing
- Demand Segmentation
OS Part-5
- Distributed Operating System: Introduction and Types
- Distributed OS: Design Issues
- Distributed OS: File System
- Distributed OS: Remote File Access
- Remote Procedure Call(RPC)
- Remote Method Invocation(RMI)
- Distributed Shared Memory
- Parallel Processing and Concurrent Programming
- Security and Threats Protection in Distributed OS
- Security Design Principles and Authentication in Distributed OS
- Sensor Network and Parallel OS
Threads in Operating System
Thread kya hota hai?
Thread ek process ke andar ek chhoti unit hoti hai jo execute hoti hai. Ek process ke multiple threads ho sakte hain jo ek saath kaam karte hain aur same memory, files, aur data share karte hain.
Example:
Socho ek web browser jaise Google Chrome:
Ek thread web page load kar raha hai.
Dusra thread user input handle kar raha hai (mouse clicks, keyboard typing).
Teesra thread background me file download kar raha hai.
Diagram: Process vs. Threads
Process: Web Browser
├── Thread 1: Load Web Page
├── Thread 2: Handle User Input
├── Thread 3: Download Files
Sabhi threads ek hi process ka hissa hain aur ek dusre ke sath memory share karte hain.
Types of Threads
Threads 2 tareeke ke hote hain:
1. User-Level Threads (ULTs)
Ye threads OS ke bina ek library dwara manage kiye jate hain.
Bahut fast aur lightweight hote hain.
Example: Java me jo threads hote hain, wo ULTs hote hain.
2. Kernel-Level Threads (KLTs)
Ye threads operating system dwara manage kiye jate hain.
Ye thode slow hote hain, lekin powerful hote hain.
Example: Windows aur Linux ke system threads.
Multithreading
Multithreading ka matlab hota hai ek process me ek saath multiple threads chalana.
Multithreading ke Benefits
CPU ka full utilization – Threads CPU ko idle nahi hone dete.
Faster Execution – Multiple kaam ek saath ho sakte hain.
Resource Sharing – Threads same process ki resources use karte hain, jo memory bachata hai.
Diagram: Multithreading
Process
├── Thread 1 (Task A)
├── Thread 2 (Task B)
├── Thread 3 (Task C)
Multithreading Models
Operating System threads ko manage karne ke liye alag-alag models use karta hai:
1. Many-to-One Model
Multiple user threads ek hi kernel thread ko use karte hain.
Limitation: Ek time me sirf ek thread run ho sakta hai.
Example: Purane Solaris OS versions.
2. One-to-One Model
Har user thread ka ek alag kernel thread hota hai.
Isme true parallel execution possible hoti hai.
Example: Windows, Linux, MacOS.
3. Many-to-Many Model
Multiple user threads multiple kernel threads ke sath linked hote hain.
Yeh best model hai kyunki isme flexibility aur performance dono ache hote hain.
Example: Modern Linux aur Solaris OS.
Thread Lifecycle
Ek thread apne execution ke dauraan different states se guzarta hai:
-> New: Jab ek thread create hota hai, par start nahi hota.
-> Ready: Thread CPU ka wait kar raha hai.
-> Running: Jab thread CPU par execute ho raha hai.
-> Blocked: Jab thread kisi event ka wait kar raha ho (jaise I/O operation).
-> Terminated: Jab thread ka execution complete ho jaye.
Diagram: Thread States
New → Ready → Running → (Blocked) → Terminated
Threads vs. Processes
Feature | Thread | Process |
---|---|---|
Memory Usage | Kam | Zyada |
Communication | Fast (Shared Memory) | Slow (IPC needed) |
Creation Time | Fast | Slow |
Context Switching | Fast | Slow |
Example | Web Browser ke Tabs | Alag-alag Applications |
Conclusion
Threads system ko efficient aur fast banate hain.
Multithreading se ek process ke multiple parts parallel chal sakte hain.
OS different models use karta hai threads ko manage karne ke liye.