This repository contains a collection of experiments, algorithms, and implementations of key operating system concepts, including process scheduling, memory allocation, disk scheduling, threads, synchronization mechanisms, and more. Each directory represents a different component or solution to specific operating system problems.
This repository serves as a comprehensive resource for understanding and implementing fundamental operating system concepts. It includes practical implementations of various algorithms and solutions to classic operating system problems, making it valuable for both learning and reference purposes.
The Scheduling Algos
directory contains implementations of various process scheduling algorithms:
- First-Come-First-Serve (FCFS) β±οΈ: Processes are executed in the order they arrive
- Shortest Job First (SJF) π: Non-preemptive scheduling based on burst time
- Round Robin (RR) π: Time-sliced scheduling with a fixed quantum
- Priority Scheduling β: Execution order based on priority values
- Shortest Remaining Time First (SRTF) β: Preemptive version of SJF
- Gantt Chart Visualization π: Added visualizations for scheduling algorithms
The Disk Scheduling Algo
directory implements common disk scheduling algorithms:
- FCFS: First-Come-First-Serve disk access
- SCAN/Elevator: Bi-directional disk arm movement
- C-SCAN: Circular SCAN algorithm
- LOOK/C-LOOK: Optimized versions of SCAN/C-SCAN
The Memory Allocation
directory contains implementations of memory allocation strategies:
- First Fit: Allocates the first available block that fits
- Best Fit: Allocates the smallest block that satisfies the request
- Worst Fit: Allocates the largest available block
- Next Fit: Modified first-fit starting from last allocation position
The Threads
directory focuses on thread management and synchronization:
- Thread Creation: Basic thread implementation
- Mutex Implementation: Mutual exclusion mechanisms
- Semaphores: Implementation of binary and counting semaphores
- Producer-Consumer Problem: Classic synchronization problem solution
The Banker's Algo
directory implements the Banker's algorithm for deadlock avoidance:
- Resource Allocation Graph: Visualization of system state
- Safety Algorithm: Determines if system is in safe state
- Resource Request Algorithm: Handles resource requests safely
The Replacement Algo
directory contains page replacement policies:
- FIFO: First-In-First-Out replacement
- LRU: Least Recently Used strategy
- Optimal: Theoretical optimal replacement policy
- Clock/Second Chance: Efficient approximation of LRU
π Race conditions occur when multiple threads access shared data simultaneously, causing unpredictable behavior. This repository demonstrates both how race conditions manifest and how to prevent them through proper synchronization.
π¦ Semaphores control access to shared resources through atomic operations. This repository implements:
- Binary Semaphores: Used for mutual exclusion (similar to locks)
- Counting Semaphores: Used for resource management with multiple units
π Deadlock situations arise when processes hold resources while waiting for others, creating a circular wait. This repository includes:
- Deadlock Detection: Algorithms to identify deadlock conditions
- Deadlock Prevention: Strategies to avoid deadlock situations
- Banker's Algorithm: Implementation of deadlock avoidance technique
πΎ Memory management techniques optimize the allocation and utilization of system memory:
- Paging: Fixed-size memory block management
- Segmentation: Variable-sized logical memory blocks
- Virtual Memory: Extended memory using disk storage
- Page Replacement: Algorithms for selecting pages to swap out
# Clone the repository
git clone https://github.com/Faisal786111/os-experiments.git
# Navigate to the repository
cd os-experiments
# Explore different experiments
cd Experiments
Contributions are welcome! If you have any improvements or new experiments to add:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-experiment
) - Commit your changes (
git commit -m 'Add some amazing experiment'
) - Push to the branch (
git push origin feature/amazing-experiment
) - Open a Pull Request