This project is a C++ based simulation of key concepts in Operating Systems (OS). It includes implementations of CPU scheduling algorithms, page replacement techniques, and synchronization mechanisms using mutexes and semaphores. The project aims to provide an educational tool for understanding process management, memory management, and inter-process communication.
- First Come First Serve (FCFS)
- Shortest Job First (SJF)
- Round Robin
- Priority Scheduling
- FIFO (First In First Out)
- 2nd Chance Algorithm
- Least Recently Used (LRU)
- Optimal Page Replacement
- Producer-Consumer Problem with Semaphores and Mutexes
- Shared Memory Implementation
- Utility functions showcasing bitwise multiplication operations
The project consists of the following files:
cpuScheduling.cpp: Contains implementations of various CPU scheduling algorithms.pageReplacement.cpp: Implements different page replacement algorithms.IGBO KENNETH EXPERIMENT CODE MUTEX AND SYNC.cpp: Demonstrates synchronization using semaphores and mutexes.bitwisemult.cpp: Contains utility functions for bitwise multiplication.
Ensure you have the following libraries installed:
- Standard C++ Libraries (
iostream,vector, etc.) - POSIX Threads (
pthread.h) - System V IPC (
sys/ipc.h,sys/shm.h)
- Clone the repository:
bash
git clone <repository-url>
- Navigate to the project directory:
bash
cd OS-Simulation-Project
- Compile the source files:
bash
g++ -o cpuScheduling cpuScheduling.cpp -lpthread
g++ -o pageReplacement pageReplacement.cpp -lpthread
g++ -o syncExperiment IGBO\ KENNETH\ EXPERIMENT\ CODE\ MUTEX\ AND\ SYNC.cpp -lpthread
g++ -o bitwisemult bitwisemult.cpp
- Run the executables:
bash
./cpuScheduling
./pageReplacement
./syncExperiment
./bitwisemult
cpp
int mode = 1; // FCFS
queuer q(processArray, arrayLength);
cpuschedule(&q, mode, &timerInstance, quartumSize);
cpp
buffer b(bufferSize);
b.refpage(pagePointer, algorithmNumber, sequenceArray, sequenceLength);
cpp
create_shared_memory();
// Initialize semaphores and threads
produce(NULL); // Producer thread function
consume(NULL); // Consumer thread function
Contributions are welcome! Please open an issue or submit a pull request if you would like to contribute.
This project is licensed under the MIT License - see the LICENSE file for details.