Skip to content

Latest commit

 

History

81 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Scheduler

A simple command scheduling system written in C for Linux.

The project is composed of two programs, runner and controller, that communicate through named pipes/FIFOs. Users submit commands with the runner, while the controller manages scheduling and controls how many commands can run at the same time.

Final grade: 20 / 20 ⭐

Overview

The system works with one central controller process and multiple runner processes.

When a user submits a command, the runner sends a request to the controller. The controller stores the request, applies the selected scheduling policy, and authorizes the command when it can run.

After receiving permission, the runner executes the command and notifies the controller when it finishes. The controller also keeps track of running and waiting commands, so users can check the current state of the system.

Supported scheduling policies:

  • Round-Robin
  • MLFQ
  • Stride
  • FCFS
  • Random

Project structure

.
├── bin/                  # Compiled binaries
├── include/              # Header files
├── logs/                 # Logs generated by the controller
├── obj/                  # Object files
├── scripts/
│   ├── plots/            # Plots generated by Python
│   ├── analyze_logs.py   # Log analysis and plot generation script
│   ├── run_tests.sh      # General test script
│   ├── scenario_stride.sh
│   ├── scenario_rr.sh
│   └── scenario_mlfq.sh
├── src/                  # Source code
│   ├── controller/
│   ├── pipes/
│   ├── runner/
│   └── utils/
├── tmp/
└── Makefile

Build

make clean
make

Usage

Start the controller

./bin/controller <max-parallel> <policy>

Available policies: round-robin, mlfq, stride, fcfs and random.

Example:

./bin/controller 3 round-robin

Run a command

./bin/runner -e <user-id> <command>

Example:

./bin/runner -e 1 echo hello

Example with pipes and redirection:

./bin/runner -e 1 "grep system /etc/passwd | wc -l > out.txt"

Check running and waiting commands

./bin/runner -c

Stop the controller

./bin/runner -s

Test scripts

The test scripts compile the project automatically and clean the logs before each run.

Inside the scripts directory:

chmod +x <script_name>.sh
./<script_name>.sh

Example:

chmod +x run_tests.sh
./run_tests.sh

Generate plots

After running the test scripts:

python3 scripts/analyze_logs.py

Python dependencies

pip3 install matplotlib numpy

Notes

This project was developed for Linux and uses system calls such as fork, exec, wait, mkfifo, open, read and write.

Authors

About

Linux command scheduler with runners, a central controller, named pipes and multiple scheduling policies.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages