Skip to content

kcflexigbo/OS-Simulation-Project

Repository files navigation

OS-Simulation-Project

Overview

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.

Features

CPU Scheduling Algorithms

  • First Come First Serve (FCFS)
  • Shortest Job First (SJF)
  • Round Robin
  • Priority Scheduling

Page Replacement Algorithms

  • FIFO (First In First Out)
  • 2nd Chance Algorithm
  • Least Recently Used (LRU)
  • Optimal Page Replacement

Synchronization Mechanisms

  • Producer-Consumer Problem with Semaphores and Mutexes
  • Shared Memory Implementation

Bitwise Operations

  • Utility functions showcasing bitwise multiplication operations

Project Structure

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.

Dependencies

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)

How to Run

  1. Clone the repository:

bash

   git clone <repository-url>
  1. Navigate to the project directory:

bash

   cd OS-Simulation-Project
  1. 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
  1. Run the executables:

bash

   ./cpuScheduling
   ./pageReplacement
   ./syncExperiment
   ./bitwisemult

Example Usage

CPU Scheduling

cpp

int mode = 1; // FCFS
queuer q(processArray, arrayLength);
cpuschedule(&q, mode, &timerInstance, quartumSize);

Page Replacement

cpp

buffer b(bufferSize);
b.refpage(pagePointer, algorithmNumber, sequenceArray, sequenceLength);

Synchronization

cpp

create_shared_memory();
// Initialize semaphores and threads
produce(NULL); // Producer thread function
consume(NULL); // Consumer thread function

Contributing

Contributions are welcome! Please open an issue or submit a pull request if you would like to contribute.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A C++ project simulating OS concepts like CPU scheduling (FCFS, SJF, Round Robin, Priority), page replacement (FIFO, 2nd Chance, LRU, Optimal), and synchronization with mutexes/semaphores. It helps understand process management, memory management, and inter-process communication.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages