A repository showcasing C programs for Applied Operating System concepts, including MUTEX, process synchronization, scheduling algorithms, SRTF, and system calls. Explore source codes demonstrating key OS principles with practical examples.
This repository contains C programs demonstrating concepts of Applied Operating Systems, including:
- MUTEX
- Process Synchronization
- Scheduling Algorithms
- Shortest Remaining Time First (SRTF)
- System Calls
These examples are designed to help understand and implement fundamental OS principles in C.
To compile and run C programs on Windows, you'll need to install MINGW (Minimalist GNU for Windows):
-
Download MINGW:
- Visit the MINGW website and download the setup installer.
-
Install MINGW:
- Run the installer and select
gcc(GNU Compiler Collection) during the installation process. - Complete the installation and ensure the
binfolder (e.g.,C:\MinGW\bin) is added to your system'sPATHenvironment variable.
- Run the installer and select
-
Verify Installation:
- Open a terminal and type:
gcc --version
- You should see the version details of GCC, confirming the setup.
- Open a terminal and type:
Ensure the following header files are included in your programs as needed:
<stdio.h>: Provides input/output functions likeprintfandscanf.<stdlib.h>: Contains utility functions likemalloc,free, and program control (e.g.,exit).<pthread.h>: Required for handling threads and implementing MUTEX and process synchronization.<unistd.h>: Provides access to POSIX operating system API functions likefork,exec, andsleep.<sys/types.h>and<sys/wait.h>: Used for system calls and process control functions likewait.<string.h>: For string handling functions likestrlenandstrcpy.<time.h>: Useful for timing and scheduling-related functions.
MUTEX (Mutual Exclusion) is used to prevent race conditions in multithreaded programs. It ensures that only one thread accesses critical sections of the code at a time.
This involves coordinating processes to ensure correct sequencing of operations. Techniques like semaphores and condition variables are used for this purpose.
Various CPU scheduling algorithms, such as:
- FCFS (First Come First Serve)
- SJF (Shortest Job First)
- Round Robin (RR)
These algorithms determine the order in which processes execute to optimize performance metrics like turnaround time and CPU utilization.
A preemptive version of SJF, where the process with the shortest remaining execution time is given priority. It is useful for time-critical applications.
System calls are the interface between a program and the operating system, enabling functionalities like process control (fork, exec), file manipulation (open, read, write), and more.
-
Clone this repository:
git clone https://github.com/your-username/your-repo.git](https://github.com/Rabin-Mishra/Applied-OS-Using-C-Programming-.git
-
Compile any program:
gcc -o program_name program_name.c -lpthread
-
Run the compiled program:
./program_name
Feel free to contribute by creating issues or submitting pull requests. Ensure your code follows proper formatting and includes comments for clarity.
This repository is licensed under the MIT License. See the LICENSE file for more details.