This project is a simple job scheduler implemented in C. It supports adding, scheduling, and executing jobs with specific commands. The job scheduler is capable of handling foreground and background jobs, with a focus on round-robin scheduling.
- Command Line Interface: Interactive prompt to enter commands.
- Builtin Commands: Support for commands like
quit
,jobs
,bg
,fg
,addjob
,schedule
, andhelp
. - Job Management: Add and schedule jobs with specified burst times and arrival times.
- Round-Robin Scheduling: Jobs are executed based on a round-robin scheduling algorithm.
- System Commands: Execute system commands like
ls
and run C programs.
- GCC compiler
- Unix-like operating system (Linux, macOS, etc.)
- WSL
To mount drive, use the following command:
sudo mkdir /mnt/c
sudo mount -t drvfs C: /mnt/c
Now, get that directory:
cd /mnt/c/shell
To compile the project, use the following command:
sudo gcc shell.c -o shell
Run the compiled program:
sudo ./shell
You will be presented with a prompt vansh>
where you can enter commands.
- quit: Exit the shell.
- jobs: Display the total number of jobs.
- bg: Display the number of background jobs.
- fg: Display the number of foreground jobs.
- addjob <name> <burst_time> <arrival_time>: Add a new job.
- schedule: Schedule and execute jobs in Round Robin manner.
- help: Display the help message with available commands.
- ls: Show files in the current directory.
- run <filename>: Compile and run a C file.
-
Adding a Job:
vansh> addjob job1 5 0
-
Scheduling Jobs:
vansh> schedule
-
Running a System Command:
vansh> ls
-
Compiling and Running a C Program:
vansh> run program.c
-
Showing What all commands are there:
vansh> help
-
Displaying number of jobs:
vansh> jobs
-
For going back to the terminal
vansh> quit
The shell provides feedback for incorrect usage or errors encountered during command execution. For example:
- Trying to add a job with incorrect arguments will display a usage message.
- Exceeding the maximum number of jobs will display an error message.
- main.c: Contains the main function, command parsing, and job scheduling logic.
- job.c: Manages job structures and scheduling functions.
- command.c: Handles command parsing and execution.
- Improve job scheduling algorithm to support more complex scenarios.
- Add support for job priorities.
- Enhance command parsing to handle more complex command structures.
This project is licensed under the MIT License.
Vansh - GitHub