Ask Computer Engineering Expert

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, describe your line of thought and your source code (for this part you can either describe 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.  

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M986071

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As