Question: Simulation Exercise 1 : Process Management Simulation Goal: To simulate five process management functions: process creation, replacing the current process image with a new process
Simulation Exercise : Process Management Simulation
Goal: To simulate five process management functions: process creation, replacing the current process image with a new process image, process state transition, process scheduling, and context switching.
You will use Linux system calls such as fork wait pipe and sleep Read man pages of these system calls for details.
This simulation exercise consists of three types of Linux processes: commander, process manager, and reporter. There is one commander process this is the process that starts your simulation one process manager process that is created by the commander process, and a number of reporter processes that get created by the process manager, as needed.
Commander Process
The commander process first creates a pipe and then a process manager process. It then repeatedly reads commands one command per second from the standard input and passes them to the process manager process via the pipe. There are four types of commands:
Q: End of one unit of time.
U: Unblock the first simulated process in blocked queue.
P: Print the current state of the system.
T: Print the average turnaround time, and terminate the system.
Command appears exactly once, being the last command.
Simulated Process
Process management simulation manages the execution of simulated processes. Each simulated process is comprised of a program that manipulates setsupdates the value of a single integer variable. Thus the state of a simulated process at any instant is comprised of the value of its integer variable and the value of its program counter. A simulated process' program consists of a sequence of instructions. There are seven types of instructions as follows:
: Set the value of the integer variable to where is an integer.
A : Add to the value of the integer variable, where is an integer.
D : Subtract from the value of the integer variable, where is an integer.
B: Block this simulated process.
E: Terminate this simulated process.
: Create a new simulated process. The new simulated process is an exact copy of the parent simulated process. The new simulated process executes from the instruction immediately after this instruction, while the parent simulated process continues its execution instructions after the next instruction.
filename: Replace the program of the simulated process with the program in the file filename, and set program counter to the first instruction of this new program.
An example of a program for a simulated is as follows:
tableSAAD A F RfileaF RfilebF R fileCF R filedF R fileeE
You may store the program of a simulated process in an array, with one array entry for each instruction.
Process Manager Process
The process manager process simulates five process management functions: creation of new simulated processes, replacing the current process image of a simulated process with a new process image, management of process state transitions, process scheduling, and context switching. In addition, it spawns a reporter process whenever it needs to print out the state of the system.
The process manager creates the first simulated process process id Program for this process is read from a file filename: init This is the only simulated process created by the process manager on its own. All other simulated processes are created in response to the execution of the instruction.
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
