A model of an operating system which uses a multithreaded approach to handle processes. This kernel
can schedule processes using 4 different types of algorithms:
• First Come First Serve
• Round Robin
• Preemptive Priority
• Shortest Job First
The aim, of embedding various scheduling algorithms in this operating system kernel, was to analyze
which scheduling algorithm works better (keeping the conditions in mind). Spark Kernel uses C++
with a twist of POSIX Threads to make processing and execution fast and efficient.
Spark kernel has an easy-to-use command-line interface. This is how you can use Spark Kernel
command line interface to apply different scheduling techniques:
• First Come First Serve: ./os-kernel
• Round Robin: ./os-kernel
• Preemptive Priority: ./os-kernel
• Shortest Job First: ./os-kernel
Spark Kernel parses these command line arguments and takes the appropriate route from there. The
input file should have the following format:
Process | Name | Priority | Arrival Time | Process Type | CPU Time | I/O Times
If you have a valid input file and use the command-line interface as instructed, you will be able to see
a live Gannt Chart of the whole operating system model. After complete execution of all processes,
you will receive the total executed time, total time spent in ready state and number of context
switches. This complete output will also be written to the text file you provide at the time of
execution. Here is a sneak peek:
int main(int, char*[]) //driver code
void init_proc(vector
void sortVec(vector
struct entry //stores pcb-related data of a process
struct compareEntry: bool operator()(entry, entry) //operator overload for priority queue
struct compareCpu: bool operator()(entry, entry) //operator overload for priority queue
struct sortEntry:inline bool operator()(const entry&, const entry&) //operator overload for sorting
struct fcfs{ //structure for first come first serve scheduling
void context_switch() //adds to number of context switches
void yield(entry) //sends process to I/O
void terminate(entry) //terminates process after execution
void wakeup(entry) //sends process back to CPU from I/O
void cpu_thread(int) //CPU thread
void io_thread(int) // I/O thread
string idle(entry) //decides if a process is idle or not
void schedule(char) //schedules all processes
fcfs(vector
}
struct round_robin{ //structure for round robin scheduling
void context_switch() //adds to number of context switches
void yield(entry) //sends process to I/O
void terminate(entry) //terminates process after execution
void preempt(entry) force-fully takes CPU for another process
void wakeup(entry) //sends process back to CPU from I/O
void cpu_thread(int) //CPU thread
void io_thread(int) // I/O thread
string idle(entry) //decides if a process is idle or not
void schedule(char) //schedules all processes
round_robin(vector
}
struct priority{ //structure for preemptive priority-based scheduling
void context_switch() //adds to number of context switches
void preempt() //force-fully takes CPU for another process
void cpu_thread(int) //CPU thread
void io_thread(int) // I/O thread
string idle(entry) //decides if a process is idle or not
void schedule(char) //schedules all processes
priority(vector
}
struct sjf{
void context_switch() //adds to number of context switches
void preempt() //force-fully takes CPU for another process
void cpu_thread(int) //CPU thread
void io_thread(int) // I/O thread
string idle(entry) //decides if a process is idle or not
void schedule(char) //schedules all processes
sjf(vector
}
An open-source GitHub library to bring color to your terminal.
Repository: https://github.com/hugorplobo/colors.hpp
Colors used for data visualization:
• Red: IDLE
• Yellow: I/O Bound Process
• Green: CPU Bound Process
The code provided is well-commented. If you have any confusions after reading the above structure,
the commented code can be used as reference.
This project has helped us strengthen all our core concepts of the Linux operating system including multiprocessing, multithreading, scheduling and synchronization. It has made us confident about being able to work on any operating systems programming task/project in the future. As our field is cyber security, the Linux operating system is very important for us to learn and this project helped us to do exactly that.