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
Critical Section Problem in Operating System
Critical Section Problem Kya Hai?
Critical Section Problem ek multi-process environment me hota hai jisme multiple processes ek shared resource (jaise ki memory, files, variables) ko access karti hain. Problem yeh hoti hai ki ek samay par sirf ek hi process shared resource ko access kare taki data inconsistency aur race condition na ho.
Important Terms:
Critical Section (CS): Program ka wo part jisme shared resource ka access hota hai.
Race Condition: Jab do ya zyada processes ek shared resource ko ek saath modify karne ki koshish karti hain, to incorrect results mil sakte hain.
Mutual Exclusion: Sirf ek process ek samay par critical section me ho sakti hai.
Critical Section Problem ka Solution
Ek sahi solution ko ye 3 conditions fulfill karni chahiye:
1. Mutual Exclusion
Sirf ek hi process ek time par critical section me ho.
2. Progress
Agar koi process critical section me nahi hai, to waiting processes ko enter karne ka mauka milna chahiye.
3. Bounded Waiting
Har process ko ek fixed time ke andar critical section me enter karne ka chance milna chahiye.
Example: Bank Account System (Race Condition Problem)
Maan lo ki do log ek bank account ko ek saath access kar rahe hain:
Person A balance check karta hai: ₹10,000
Person B balance check karta hai: ₹10,000
Person A ₹5,000 withdraw karta hai → New balance ₹5,000 hona chahiye.
Person B ₹3,000 withdraw karta hai → Ideally, balance ₹2,000 hona chahiye.
Agar dono transactions ek saath chal rahi hain, to final balance ₹7,000 dikhega, jo ki galat hai!
Problem: Dono transactions ek saath chalne ki wajah se final balance incorrect ho gaya.
Solution: Critical Section techniques ka use karke ensure karna ki ek transaction complete hone ke baad hi dusra start ho.
Critical Section Problem ke Solutions
1. Hardware-Based Solutions
Interrupts Disable Karna: Ek time par sirf ek process chalegi, par yeh inefficient hai.
Test-and-Set Lock: Ek special instruction jo ensure karti hai ki ek samay par sirf ek process CS me ho.
2. Software-Based Solutions
Peterson’s Algorithm
Dekker’s Algorithm
Bakery Algorithm (Har process ek “token” leti hai aur order ke hisaab se enter karti hai).
3. Synchronization Tools
Mutex (Mutual Exclusion Lock): Sirf ek process ko allow karta hai.
Semaphores: Ek counter system jisme multiple processes ka access control hota hai.
Monitors: Object-oriented synchronization technique jo process coordination ko manage karti hai.
Diagram: Critical Section Execution
Process 1 Process 2
----------------------------------------
Entry Section Entry Section
Check CS free hai? Check CS free hai?
Agar free hai to enter Wait karo agar occupied hai
Modify Shared Data Modify Shared Data
Exit CS Process 1 exit hone ke baad enter karo
Continue Execution Continue Execution
Conclusion
Critical Section Problem multiprocessor systems me important hai kyunki ye race conditions ko prevent karta hai.
Mutual Exclusion, Progress, aur Bounded Waiting ko ensure karna zaroori hai.
Mutex, Semaphores, aur Monitors jaise solutions shared resource access ko safe banate hain.