Welcome to the CSE3003 - Operating System Repository! This repository contains implementations of various OS algorithms in C++. Whether you're a student studying OS or a developer looking to understand these algorithms better, this repository aims to provide clear and concise implementations along with explanations to aid your learning.
This project is a comprehensive collection of various Operating System (OS) algorithms implemented in C++. It aims to provide a clear understanding of these algorithms through well-documented code and explanations. The repository is designed to be a valuable resource for students, developers, and anyone interested in learning about OS algorithms.
This project is made using C++ programming language. Each algorithm is implemented in its own directory with a corresponding README file that explains the algorithm's logic and how to use the implementation. The project uses standard C++ libraries and follows best practices for coding and documentation.
This project stands out due to its comprehensive coverage of various OS algorithms, clear and concise code implementations, and detailed explanations. Each algorithm is implemented in a way that is easy to understand and follow, making it an excellent learning resource. The project also includes example usage and code analysis sections for each algorithm, providing a deeper understanding of how the algorithms work.
Compared to similar projects, this repository offers a more detailed and structured approach to learning OS algorithms. The code is well-documented, and each algorithm is accompanied by a README file that explains the logic and usage. This makes it easier for users to understand and experiment with the algorithms. Additionally, the project covers a wide range of OS algorithms, providing a comprehensive learning resource.
This project leverages the C++ programming language and standard libraries to implement the OS algorithms. It also uses modern C++ features and best practices to ensure the code is efficient, readable, and maintainable. The project is designed to be easily extensible, allowing users to add new algorithms or modify existing ones.
To run this project, follow these steps:
- Clone the repository to your local machine using
git clone https://github.com/Pulkit1822/CSE3003-Operating-System.git
. - Navigate to the directory of the algorithm you want to run.
- Follow the instructions provided in the README file of the respective algorithm to compile and run the code.
- Experiment with different inputs and configurations to observe the behavior of the algorithm.
Contributions to this repository are welcome and encouraged. If you would like to contribute:
- Fork the repository and create your branch from
main
. - Ensure any new code is well-documented and follows the established coding style.
- Create a pull request with a clear description of your changes and their rationale.
-
Round Robin Scheduler: This algorithm is a preemptive scheduler where each process is assigned a fixed time slice or quantum. Once a process consumes its quantum, it's moved to the back of the ready queue to await its turn again. This implementation demonstrates how round-robin scheduling can be achieved efficiently in C++.
-
Priority Scheduler: Priority scheduling assigns priorities to each process, and the CPU is allocated to the process with the highest priority. In case of ties, a round-robin approach can be used. This implementation showcases how to implement priority scheduling and handle priorities effectively.
-
Shortest Job First (SJF): SJF scheduling algorithm selects the process with the smallest execution time next. This implementation demonstrates how to implement SJF scheduling in C++.
-
First-Come, First-Served (FCFS): FCFS scheduling algorithm executes processes in the order they arrive in the ready queue. This implementation demonstrates how to implement FCFS scheduling in C++.
-
Semaphore: It demonstrates the implementation of semaphores for synchronization in a producer-consumer scenario. It creates a semaphore, allows the producer to produce items, and the consumer to consume them from a shared buffer. Semaphores are used to control access to the buffer and ensure proper synchronization between the producer and consumer processes.
-
Producer-Consumer Problem: It illustrates the classic producer-consumer problem using semaphores for synchronization. It sets up a shared buffer where the producer produces items and the consumer consumes them. Semaphores are employed to coordinate access to the buffer, preventing race conditions and ensuring orderly item production and consumption between the two processes.
-
Banker's Algorithm: The Banker's Algorithm in OS is a resource allocation and deadlock avoidance algorithm. It helps prevent deadlock conditions by ensuring that resource allocation does not lead to a deadlock. The algorithm is based on the concept of a bank, where the bank never allocates more resources than what is available. It checks whether granting resources would lead to a deadlock and only grants resources if it would not result in a deadlock. It is mainly used to prevent deadlock.
-
Resource Allocation Graph: The Resource Allocation Graph (RAG) is a graphical representation that provides information about the state of the system in terms of processes and resources. It shows which resources are held by which processes and can help identify deadlocks. The vertices in a RAG represent processes and resources, with processes typically represented by circles and resources by rectangles. The edges in a RAG represent assignments (resources assigned to processes) and requests (processes waiting for resources). If there is a cycle in the RAG, it indicates a deadlock.
Each algorithm implementation is contained within its own directory along with a README file explaining the algorithm's logic and how to use the implementation. To use any algorithm:
- Navigate to the respective algorithm's directory.
- Follow the instructions provided in the README to compile and run the code.
- Experiment with different inputs and configurations to observe the behavior of the algorithm.
Contributions to this repository are welcome and encouraged. If you would like to contribute:
- Fork the repository and create your branch from
main
. - Ensure any new code is well-documented and follows the established coding style.
- Create a pull request with a clear description of your changes and their rationale.
If you have any feedback, suggestions, or questions regarding this repository, please feel free to open an issue or contact me below on any of the platforms you prefer 😊
Happy learning and coding!
If you find this repository useful, don't forget to star it! ⭐️