Command f changes the status of the current process


The commander process creates a process manager process. It then repeatedly reads commands from the standard input and passes them to the process manager process. The commander process accepts four commands:

1. U: Unblock the first simulated process in blocked queue. 
2. P: Print the current state of the system. 
3. R: Run a simulated process.
4. T: Terminate the program.

Simulated Process:
Process management simulation manages the execution of simulated processes. Each simulated process is comprised of a program that manipulates 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.

A simulated process' program consists of a sequence of instructions. There are seven types of instructions as follows:

1. S n: Set the value of the integer variable to n, where n is an integer. 
2. A n: Add n to the value of the integer variable, where n is an integer. 
3. B n: Subtract n from the value of the integer variable, where n is an integer. 
4. D : Display the value of n.
5. E : Display the information about this process.
6. F : Block this simulated process. 
7. H : Terminate this simulated process.

You use C++ language to implement this lab. You will submit to the dropbox three separate files:

C++ program (source code)
Executable file (object), and
Lab report, explain your line of thought and your source code (for this part you can either explain your source code in your lab report or you can add comments directly to your code)

For delivery you can divide this lab into the following three steps:

Menu interface:

In this lab we have two Menus:

1. 
U: Unblock the first simulated process in blocked queue. 
P: Print the current state of the system. 
R: Run a simulated process.
T: Terminate the program.

The program starts with this set of commands as its first menu. Then the user chooses from one of these commands. You use cin to get the input from the user, then use either if else or casestatements to specify which command the user has chosen and based on the input perform the specified task.

Options U and R would take you to the second menu and create a new process. So you can either eliminate the U command from the list or you can have both U and R perform the same task which is creating and running a new process.

Option P will output the current state of the system. The following are what you need to display in the table format shown:

PID PPID Value Start Time Status


PID: Process ID - when a process is created you assign an ID to it. The first process ID is 1, the ID for the second process would be 2, so on and so forth.

PPID: Parent Process ID - (for the sake of simplifying the problem) let's assume for instance when process 4 is being created the PID is 4 and PPID should be 3.

Value: will show the value of the variable in the process that the user has entered (program asks for this value in the second menu). If no value is entered yet for the variable the table should show N/A.

Status: should display the process status. Its value is either Running or Blocked or Terminated.

If option T is chosen, you should terminate the program and exit. 

2. 
S n: Set the value of the integer variable to n, where n is an integer. 
A n: Add n to the value of the integer variable, where n is an integer. 
B n: Subtract n from the value of the integer variable, where n is an integer. 
D : Display the value of n.
E : Display the information about this process.
F : Block this simulated process. 
H : Terminate this simulated process.

Again you can use either if else or case statement to implement this menu. For the first three commands S, A and B after the user enters the option (S or A or B) then the 
program asks for the value of n and uses the second cin to assign the value the user enters for variable n. 

In command S you just need to assign the entered value n to the variable in the current process. In command A the user enters a new value for n, that value is added to the value of the integer variable in your process (this value has either been entered by the user or initialized value is used). In command B the value of n is subtracted from the value of the integer variable. In command Dyou display the value of n that the user has entered. In command E you display the information about the current process, for this part you use the same table with the same columns as commandP in the first menu, the difference is that command P shows the values for the columns of the table for all processes so far created, running, blocked and terminated. But command E only shows the information for the current process. Command F changes the status of the current process from running to blocked and sends the control to the first menu. Command H also sends the control to the first menu, but it changes the status of the process from running to terminated. 

Output table:
This part of the lab focuses on displaying the output table. As mentioned earlier the format of the output table should be as follow containing the specified information:

PID PPID Value Start Time Status

The value of each column goes under the column and each process will have a row entry for that process.

Processing:

For this part of lab you need to have your own algorithm and design. I will provide you some hints which you can follow (although you are not required to follow this design). You can have the following functions:

A function to create a process. In this function you set the value of PID, PPID, status and the integer variable.
A function to set the value of the variable to n, the number the user has entered. This function will have one parameter which is the value of n.
A function that adds the entered value to the value of the variable.
A function that subtracts the entered value from the value of the variable.
A function that sets the value of each process status.

Again this explanation is ONLY a suggestion on how you can implement your program. You can have a different approach, which means you might not want to use these functions.  

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Command f changes the status of the current process
Reference No:- TGS086071

Expected delivery within 24 Hours