This poject implement a proccess managment system that simulates how an operating system performs process sheduling, resource allocation and deadloack dectection. The system supports both single-core and multi-core simulations with three different scheduling algorithms.
- Process Management: Full Process Control Block (PCB) management
- Resource Management: Request and release resources with proper allocation and waiting queues
- Three Scheduling Algorithms:
- First-Come, First-Served (FCFS)
- Round Robin (RR) with configurable time quantum
- Priority-based Preemptive Scheduling
- Multi-core Simulation: Parallel execution using OpenMP threads
- Deadlock Detection: Identifies deadlocked processes and blocked processes
- Comprehensive Logging: Detailed output for debugging and analysis
Processes run in arrival order. Each process executes until it blocks on a resource request or exhausts its instruction list.
Processes run for a fixed time_quantum number of instructions before being preempted and returned to the back of the ready queue.
The process with the lowest priority number runs at all times. After every instruction, the scheduler checks whether a higher-priority process has entered the ready queue (via a new arrival or a wakeup). If so, the current process is preempted and returned to the ready queue.
├── data
│ ├── process1.list
│ └── process2.list
├── Makefile
├── README.md
├── run.sh
├── core
│ ├── inc
│ │ ├── logger.h // Definition of logger.c functions
│ │ ├── manager.h // Defination of manager.c fucntions and data struture
│ │ ├── proc_gen.h // Definition of proc_gen.c functions
│ │ ├── proc_parser.h // Defination of proc_parser.c
│ │ ├── proc_structs.h // Defines OS data structures
│ │ └── proc_syntax.h // Defines parser's language keywords
│ └── src
│ ├── logger.c // Logs system events to files
│ ├── manager.c // Core scheduling logic
│ ├── proc_gen.c // Generates random test processes
│ ├── proc_loader.c // Manages OS process and resource loading
│ └── proc_parser.c // Parses process configuration files
└── tests
├── input
│ ├── 00_process1.list
│ ├── 01_empty.list
│ │ ⋮
│ ├── 20_unknown_instr.list
│ └── 21_unknown_instr_multi.list
└── expected
├── 0_00_process1.log.exp
├── 0_00_process1.out.exp
│ ⋮
├── 2_21_unknown_instr_multi.log.exp
└── 2_21_unknown_instr_multi.out.exp
- GCC compiler with OpenMP support
- Make utility
- Linux/Unix environment (or WSL on Windows)
# Standard build
gcc -fopenmp -Icore/inc -o schedule_processes core/src/*.c -lm
# With debug output
gcc -fopenmp -DDEBUG -Icore/inc -o schedule_processes core/src/*.c -lm
# With Makefile
make
make DEBUG=-DDEBUG_MNGR./schedule_processes <num_threads> <data> <scheduler> <time_quantum>
| Argument | Description |
|---|---|
num_threads |
Number of simulated CPU cores (OpenMP threads) |
data |
Path to a .list process file, or generate for random generation |
scheduler |
0 = Priority, 1 = Round Robin, 2 = FCFS |
time_quantum |
Number of instructions per timeslice (used by Round Robin only) |
Examples:
# Run with 1 thread, generated processes, Round Robin, quantum = 2
./schedule_processes 1 generate 1 2
# Run with 4 threads, a process file, Priority scheduling
./schedule_processes 4 processes.list 0 1
# FCFS with a single core
./schedule_processes 1 processes.list 2 1For each thread or process, two files are written during execution:
| File | Contents |
|---|---|
thr<id>.log |
Internal scheduling events (acquire, release, wakeup) |
thr<id>.out |
Full execution trace including queue states |
When the DEBUG flag is set, all output is mirrored to stdout.