Week 2: Process Management: Processes, Threads, Interprocess Communication – iLab
Lab2 of 7:Process Management Simulation(50 Points)
L A B A C C E S S |
Accessing Your Lab |
To access your labs after you’ve logged in, apply the following steps:
Starting Your Lab |
There are two ways to start a lab activity:
L A B O V E R V I E W |
Scenario/Summary |
Process Management Simulation (Part 2 of 3)
The objective of this three section lab is to simulate four process management functions:process creation, replacing the current process image with a new process image, process state transition, process scheduling.
This lab will be due over the first three weeks of this course. The commander process program is due in week 1. This program will introduce the student to system calls and other basic operating system functions. The process manager functions:process creation,replacing the current process image with a new process imageandprocess state transition, are due in week 2. The scheduling section of the process manager is due in week 3.
You will use Linux system calls such as fork( ), exec(), wait( ), pipe( ), and sleep( ). Read man pages of these system calls for details.
This simulation exercise consists of three processes running on a Linux environment:commander,process manager, andreporter. 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.
1. Commander Process:
The commander process first creates a pipe and then the process manager process. It then repeatedly reads commands from the standard input and passes them to the process manager process via the pipe. The commander process accepts four commands:
1.Q: End of one unit of time.
2.U: Unblock the first simulated process in blocked queue.
3.P: Print the current state of the system.
4.T: Print the average turnaround time, and terminate the system.
CommandTcan only be executed once.
1.1 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 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:
1.Sn: Set the value of the integer variable to n, where n is an integer.
2.An: Add n to the value of the integer variable, where n is an integer.
3.Dn: Subtract n from the value of the integer variable, where n is an integer.
4.B: Block this simulated process.
5.E: Terminate this simulated process.
6.Fn: 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 (F) instruction, while the parent (simulated) process continues its execution n instructions after the next instruction.
7.Rfilename: 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 process is as follows:
S 1000
A 19
A 20
D 53
A 55
F 1
R file_a
F 1
R file_b
F 1
R file_c
F 1
R file_d
F 1
R file_e
E
You may store the program of a simulated process in an array, with one array entry for each instruction.
2. Process Manager Process:
The process manager process simulates four 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, andprocess scheduling. 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 = 0) program from an input 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 theFinstruction (read from the simulated processes).
2.1 Data structures:
The process manager maintains six data structures:Time, Cpu, PcbTable, ReadyState, BlockedState, and RunningState.
2.2 Processing input commands:
After creating the first process and initializing all its data structures, the process manager repeatedly receives and processes one command at a time from the commander process (read via the pipe). On receiving aQcommand, the process manager executes the next instruction of the currently running simulated process, increments program counter value (except forForRinstructions), incrementsTime, and then performs scheduling. Note that scheduling may involve performing context switching.
On receiving aUcommand, the process manager moves the first simulated process in the blocked queue to the ready state queue array. On receiving aPcommand, the process manager spawns a new reporter process. On receiving aTcommand, the process manager first spawns a reporter process and then terminates after termination of the reporter process. The process manager ensures that no more than one reporter process is running at any moment.
2.3 Executing simulated processes:
The process manager executes the next instruction of the currently running simulated process on receiving aQcommand from the commander process. Note that this execution is completely confined to theCpudata structure, i.e.PcbTableis not accessed.
InstructionsS,AandDupdate the integer value stored inCpu. InstructionBmoves the currently running simulated process to the blocked state and moves a process from the ready state to the running state. This will result in a context switch. InstructionEterminates the currently running simulated process, frees up all memory (e.g. program array) associated with that process and updates thePcbTable. A simulated process from the ready state is moved to running state. This also results in a context switch.
InstructionFresults in the creation of a new simulated process. A new entry is created in thePcbTablefor this new simulated process. A new (unique) process id is assigned and the parent process id is process id of the parent simulated process. Start time is set to the currentTimevalue and CPU time used so far is set to 0. The program array and integer value of the new simulated process are a copy of the program array and integer value of the parent simulated process. The new simulated process has the same priority as the parent simulated process. The program counter value of the new simulated process is set to the instruction immediately after theFinstruction, while the program counter value of the of the parent simulated process is set toninstructions after the next instruction (instruction immediately afterF). The new simulated process is created in the ready state.
Finally, theRinstruction results in replacing the process image of the currently running simulated process. Its program array is overwritten by the code in filefilename, program counter value is set to 0, and integer value is undefined. Note that all these changes are made only in theCpudata structure. Process id, parent process id, start time, CPU time used so far, state, and priority remain unchanged.
2.4 Scheduling
The process manager also implements a scheduling policy. You may experiment with a scheduling policy of multiple queues with priority classes. In this policy, the first simulated process (created by the process manager) starts with priority 0 (highest priority). There are a maximum of four priority classes. Time slice (quantum size) for priority class 0 is 1 unit of time; time slice for priority class 1 is 2 units of time; time slice for priority class 2 is 4 units of time; and time slice for priority class 3 is 8 units of time. If a running process uses its time slice completely, it is preempted and its priority is lowered. If a running process blocks before its allocated quantum expires, its priority is raised.
3. Reporter Process
The reporter process prints the current state of the system on the standard output and then terminates. The output from the reporter process appears as follows:
****************************************************************
The current system state is as follows:
****************************************************************\
CURRENT TIME:time
RUNNING PROCESS:
pid, ppid, priority, value, start time, CPU time used so far
BLOCKED PROCESSES:
Queue of blocked processes:
pid, ppid, priority, value, start time, CPU time used so far
pid, ppid, priority, value, start time, CPU time used so far
PROCESSES READY TO EXECUTE:
Queue of processes with priority 0:
pid, ppid, value, start time, CPU time used so far
pid, ppid, value, start time, CPU time used so far
Queue of processes with priority 3:
pid, ppid, value, start time, CPU time used so far
pid, ppid, value, start time, CPU time used so far
****************************************************************
Deliverables |
You will submit to the dropbox, for week 2, three separate files:
L A B S T E P S |
Process Manager(50 points) |
The program for the process manager functions:process creation,replacing the current process image with a new process imageandprocess state transition, are duethis week. This program is to be written in C or C++ programming languages on a Linux environment.
IMPORTANT:Please make sure that any question or clarification about these labs are addressed early.
2. Process Manager Process:
The process manager process simulates four 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, andprocess scheduling. 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 = 0) program from an input 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 theFinstruction (read from the simulated processes).
2.1 Data structures:
The process manager maintains six data structures:Time, Cpu, PcbTable, ReadyState, BlockedState, and RunningState.
2.2 Processing input commands:
After creating the first process and initializing all its data structures, the process manager repeatedly receives and processes one command at a time from the commander process (read via the pipe). On receiving aQcommand, the process manager executes the next instruction of the currently running simulated process, increments program counter value (except forForRinstructions), incrementsTime, and then performs scheduling. Note that scheduling may involve performing context switching.
On receiving aUcommand, the process manager moves the first simulated process in the blocked queue to the ready state queue array. On receiving aPcommand, the process manager spawns a new reporter process. On receiving aTcommand, the process manager first spawns a reporter process and then terminates after termination of the reporter process. The process manager ensures that no more than one reporter process is running at any moment.
2.3 Executing simulated processes:
The process manager executes the next instruction of the currently running simulated process on receiving aQcommand from the commander process. Note that this execution is completely confined to theCpudata structure, i.e.PcbTableis not accessed.
InstructionsS,AandDupdate the integer value stored inCpu. InstructionBmoves the currently running simulated process to the blocked state and moves a process from the ready state to the running state. This will result in a context switch. InstructionEterminates the currently running simulated process, frees up all memory (e.g. program array) associated with that process and updates thePcbTable. A simulated process from the ready state is moved to running state. This also results in a context switch.
InstructionFresults in the creation of a new simulated process. A new entry is created in thePcbTablefor this new simulated process. A new (unique) process id is assigned and the parent process id is process id of the parent simulated process. Start time is set to the currentTimevalue and CPU time used so far is set to 0. The program array and integer value of the new simulated process are a copy of the program array and integer value of the parent simulated process. The new simulated process has the same priority as the parent simulated process. The program counter value of the new simulated process is set to the instruction immediately after theFinstruction, while the program counter value of the of the parent simulated process is set toninstructions after the next instruction (instruction immediately afterF). The new simulated process is created in the ready state.
Finally, theRinstruction results in replacing the process image of the currently running simulated process. Its program array is overwritten by the code in filefilename, program counter value is set to 0, and integer value is undefined. Note that all these changes are made only in theCpudata structure. Process id, parent process id, start time, CPU time used so far, state, and priority remain unchanged.
AdditionalInformation for the Process Manager: |
1.1 Simulated Process:
Are you busy and do not have time to handle your assignment? Are you scared that your paper will not make the grade? Do you have responsibilities that may hinder you from turning in your assignment on time? Are you tired and can barely handle your assignment? Are your grades inconsistent?
Whichever your reason is, it is valid! You can get professional academic help from our service at affordable rates. We have a team of professional academic writers who can handle all your assignments.
Students barely have time to read. We got you! Have your literature essay or book review written without having the hassle of reading the book. You can get your literature paper custom-written for you by our literature specialists.
Do you struggle with finance? No need to torture yourself if finance is not your cup of tea. You can order your finance paper from our academic writing service and get 100% original work from competent finance experts.
Computer science is a tough subject. Fortunately, our computer science experts are up to the match. No need to stress and have sleepless nights. Our academic writers will tackle all your computer science assignments and deliver them on time. Let us handle all your python, java, ruby, JavaScript, php , C+ assignments!
While psychology may be an interesting subject, you may lack sufficient time to handle your assignments. Don’t despair; by using our academic writing service, you can be assured of perfect grades. Moreover, your grades will be consistent.
Engineering is quite a demanding subject. Students face a lot of pressure and barely have enough time to do what they love to do. Our academic writing service got you covered! Our engineering specialists follow the paper instructions and ensure timely delivery of the paper.
In the nursing course, you may have difficulties with literature reviews, annotated bibliographies, critical essays, and other assignments. Our nursing assignment writers will offer you professional nursing paper help at low prices.
Truth be told, sociology papers can be quite exhausting. Our academic writing service relieves you of fatigue, pressure, and stress. You can relax and have peace of mind as our academic writers handle your sociology assignment.
We take pride in having some of the best business writers in the industry. Our business writers have a lot of experience in the field. They are reliable, and you can be assured of a high-grade paper. They are able to handle business papers of any subject, length, deadline, and difficulty!
We boast of having some of the most experienced statistics experts in the industry. Our statistics experts have diverse skills, expertise, and knowledge to handle any kind of assignment. They have access to all kinds of software to get your assignment done.
Writing a law essay may prove to be an insurmountable obstacle, especially when you need to know the peculiarities of the legislative framework. Take advantage of our top-notch law specialists and get superb grades and 100% satisfaction.
We have highlighted some of the most popular subjects we handle above. Those are just a tip of the iceberg. We deal in all academic disciplines since our writers are as diverse. They have been drawn from across all disciplines, and orders are assigned to those writers believed to be the best in the field. In a nutshell, there is no task we cannot handle; all you need to do is place your order with us. As long as your instructions are clear, just trust we shall deliver irrespective of the discipline.
Our essay writers are graduates with bachelor's, masters, Ph.D., and doctorate degrees in various subjects. The minimum requirement to be an essay writer with our essay writing service is to have a college degree. All our academic writers have a minimum of two years of academic writing. We have a stringent recruitment process to ensure that we get only the most competent essay writers in the industry. We also ensure that the writers are handsomely compensated for their value. The majority of our writers are native English speakers. As such, the fluency of language and grammar is impeccable.
There is a very low likelihood that you won’t like the paper.
Not at all. All papers are written from scratch. There is no way your tutor or instructor will realize that you did not write the paper yourself. In fact, we recommend using our assignment help services for consistent results.
We check all papers for plagiarism before we submit them. We use powerful plagiarism checking software such as SafeAssign, LopesWrite, and Turnitin. We also upload the plagiarism report so that you can review it. We understand that plagiarism is academic suicide. We would not take the risk of submitting plagiarized work and jeopardize your academic journey. Furthermore, we do not sell or use prewritten papers, and each paper is written from scratch.
You determine when you get the paper by setting the deadline when placing the order. All papers are delivered within the deadline. We are well aware that we operate in a time-sensitive industry. As such, we have laid out strategies to ensure that the client receives the paper on time and they never miss the deadline. We understand that papers that are submitted late have some points deducted. We do not want you to miss any points due to late submission. We work on beating deadlines by huge margins in order to ensure that you have ample time to review the paper before you submit it.
We have a privacy and confidentiality policy that guides our work. We NEVER share any customer information with third parties. Noone will ever know that you used our assignment help services. It’s only between you and us. We are bound by our policies to protect the customer’s identity and information. All your information, such as your names, phone number, email, order information, and so on, are protected. We have robust security systems that ensure that your data is protected. Hacking our systems is close to impossible, and it has never happened.
You fill all the paper instructions in the order form. Make sure you include all the helpful materials so that our academic writers can deliver the perfect paper. It will also help to eliminate unnecessary revisions.
Proceed to pay for the paper so that it can be assigned to one of our expert academic writers. The paper subject is matched with the writer’s area of specialization.
You communicate with the writer and know about the progress of the paper. The client can ask the writer for drafts of the paper. The client can upload extra material and include additional instructions from the lecturer. Receive a paper.
The paper is sent to your email and uploaded to your personal account. You also get a plagiarism report attached to your paper.
PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET A PERFECT SCORE!!!
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more