/Simple-shell-os

Simple-shell-os is a basic OS with a minimalistic shell interface, ideal for learning and experimentation. It features process management, file system handling, and basic command execution.

Primary LanguageC

Simple-shell-os

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.

Features

  • Command Line Interface: Interactive prompt to enter commands.
  • Builtin Commands: Support for commands like quit, jobs, bg, fg, addjob, schedule, and help.
  • 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.

Getting Started

Prerequisites

  • GCC compiler
  • Unix-like operating system (Linux, macOS, etc.)
  • WSL

If folder is stored in c drive

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

image

Compilation

To compile the project, use the following command:

sudo gcc shell.c -o shell 

image

Running

Run the compiled program:

sudo ./shell

image

You will be presented with a prompt vansh> where you can enter commands.

Usage

Builtin 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.

Examples

  • Adding a Job:

    vansh> addjob job1 5 0

image

  • Scheduling Jobs:

    vansh> schedule

image

  • Running a System Command:

    vansh> ls

image

  • Compiling and Running a C Program:

    vansh> run program.c

image

  • Showing What all commands are there:

    vansh> help

image

  • Displaying number of jobs:

    vansh> jobs

image

  • For going back to the terminal

    vansh> quit

image

Error Handling

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.

Code Structure

  • 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.

Future Enhancements

  • Improve job scheduling algorithm to support more complex scenarios.
  • Add support for job priorities.
  • Enhance command parsing to handle more complex command structures.

License

This project is licensed under the MIT License.

Author

Vansh - GitHub