Question: In this assignment, you are asked to build a mini OS ( shell + scheduler ) . We talked about a user process could be
In this assignment, you are asked to build a mini OS shell scheduler
We talked about a user process could be characterized by alternative CPU and IO operations, ie any process consists of c i c i c i c cm im where the values of cm im are determined by the user process behavior implementation of the algorithm in solving different problems
In evaluating the OS scheduler impact on the use processes, we only need to consider the CPU cycles of the user processes. Hence, the first task is to create simulate user processes with only CPU cycle, the user process could use an infinite loop to implement. When the process is scheduled to run, it prints a line of output in each iteration with the format of Process #### at iteration @@@ where #### is the process ID assigned by the OS and @@@ is a counter starting from to mimic the execution progress. of the process.
A sample implementation of such a process could be as follows:
int mainint argc, char argv
initialization and other necessary operations
signal handler registration: for example, you could define mysighandler then call from here
signalSIGINT mysighandler;
while
printfProcess d at iteration d
mypid, count;
sleep; you could also use usleep with specified high resolution time length
The second task is to create a Shell, which is a command interpreter that is used for users to interact with the system. When Shell starts, it will first print out a prompt eg "shell then wait for command inputs from the user.
For the shell implementation, you can envision it as an ongoing process that patiently awaits user input, interprets the provided commands, and takes appropriate actions accordingly. A sample code could be as follows:
while
readsize getline&buffer, &size, stdin;
handling on readsize;
interprets the buffer to get the command and its parameters...
switchcommand
case x:
handling x command
break;
case l:
handling l command
break;
etc... for other commands
The following commands should be implemented:
x: when a user inputs x X your Shell "system" should exit including the shell and all the processes created throughby the Shell.
c n: create n a natural number processes with the fork system call, the user processes use exec system call to load the program defined in first task above. The number of processes n should be at least and no more than for debugging purpose. The shell creates users processes P P P Pn a smaller process number the subscript of Pi where in indicates it arrives at the system earlier. Also the process number can be used in the Shell to manage the processes. In order to mimic the ready state, you could suspend them immediately when it starts SIGSTOP so the process' state is ready.
CtrlC handler should be implemented to suspend the currently running process and transfer the control to the scheduler shell prompt, after this command, the user can interact with system through running use the commands, such as checking to check the status of processes, configuring scheduling algorithms, etc., after that the 'scheduler' can schedule another process to run
l: to list the current user processes in the system including it PID underlying process ID from the host OS Ubuntu process number, and state.
s rr q: to set the scheduler to be round robin with time quantum of q time units seconds
s fcfs: to set the scheduler to be first come first serve, the process number determines its arrival order.
k #: to kill a process with process number # then state of the process # is "terminated".
r #: resume process with process number # which was suspended by CtrlC the process # is put back into ready queue and enables the scheduler
r all: run all the processes after configurations eg specifying the scheduling algorithms which essentially enables your scheduler.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
