SlideShare a Scribd company logo
1 of 11
Lab 3 of 7: Process Management Simulation
L A B O V E R V I E W
Scenario/Summary
Process Management Simulation (Part 3 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,
and
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 image
and
process 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
, 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.
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.
Command
T
can 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.
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.
D
n: 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.
F
n: 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.
R
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 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
, and
process 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 the
F
instruction (read from the simulated processes).
2.1 Data structures:
The process manager maintains six data structures:
Time, Cpu, PcbTable, ReadyState, BlockedState,
and
RunningState
.
Time
is an integer variable initialized to zero.
Cpu
is used to simulate the execution of a simulated process that is
in running state. It should include data members to store a
pointer to the program array, current program counter value,
integer value, and time slice of that simulated process. In
addition, it should store the number of time units used so far in
the current time slice.
PcbTable
is an array with one entry for every simulated process that
hasn't finished its execution yet. Each entry should include data
members to store process ID, parent process ID, a pointer to
program counter value (initially 0), integer value, priority,
state, start time, and CPU time used so far.
ReadyState
stores all simulated processes (PcbTable indices) that are ready
to run. This can be implemented using a queue or priority queue
data structure.
BlockedState
stores all processes (PcbTable indices) that are currently
blocked. This can be implemented using a queue data structure.
RunningState
stores the PcbTable index of the currently running simulated
process.
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 a
Q
command, the process manager executes the next instruction of
the currently running simulated process, increments program
counter value (except for
F
or
R
instructions), increments
Time
, and then performs scheduling. Note that scheduling may
involve performing context switching.
On receiving a
U
command, the process manager moves the first simulated
process in the blocked queue to the ready state queue array. On
receiving a
P
command, the process manager spawns a new reporter process.
On receiving a
T
command, 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 a
Q
command from the commander process. Note that this
execution is completely confined to the
Cpu
data structure, i.e.,
PcbTable
is not accessed.
Instructions
S
,
A,
and
D
update the integer value stored in
Cpu
. Instruction
B
moves 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. Instruction
E
terminates the currently running simulated process, frees up all
memory (e.g., program array) associated with that process and
updates the
PcbTable
. A simulated process from the ready state is moved to running
state. This also results in a context switch.
Instruction
F
results in the creation of a new simulated process. A new entry
is created in the
PcbTable
for this new simulated process. A new (unique) process ID is
assigned and the parent process ID is the process ID of the
parent simulated process. Start time is set to the current
Time
value 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 the
F
instruction, while the program counter value of the of the
parent simulated process is set to
n
instructions after the next instruction (instruction immediately
after
F
). The new simulated process is created in the ready state.
Finally, the
R
instruction results in replacing the process image of the
currently running simulated process. Its program array is
overwritten by the code in file
filename
, program counter value is set to 0, and integer value is
undefined. Note that all these changes are made only in the
Cpu
data 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 three separate files to the dropbox for Week 3:
C or C++ program (source code)
Executable file (object), and
Instructions to execute the program
L A B S T E P S
Process Manager Scheduling
(25 points)
The programs for the process scheduling and the reporter
process are due this week. These programs are to be written in
C or C++ programming languages on a Linux environment.
IMPORTANT: Please make sure that any questions or
clarification about these labs are addressed early.
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.
Reporter Process Requirements
(25 points)
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
*****************************************************
***********

More Related Content

Similar to Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx

Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxdenneymargareta
 
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxSheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxbagotjesusa
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - IntroductionTo Sum It Up
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2) rohassanie
 
Runtime performance evaluation of embedded software
Runtime performance evaluation of embedded softwareRuntime performance evaluation of embedded software
Runtime performance evaluation of embedded softwareMr. Chanuwan
 
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02NNfamily
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process ConceptsMukesh Chinta
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfsravi07
 
Operating system Q/A
Operating system Q/AOperating system Q/A
Operating system Q/AAbdul Munam
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OSC.U
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringYogesh Santhan
 
Operating System
Operating SystemOperating System
Operating SystemGowriLatha1
 
Process management
Process managementProcess management
Process managementBirju Tank
 

Similar to Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx (20)

Programming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docxProgramming Assignment #2CSci 430 Spring 2019Dates.docx
Programming Assignment #2CSci 430 Spring 2019Dates.docx
 
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxSheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
 
Experimentos lab
Experimentos labExperimentos lab
Experimentos lab
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - Introduction
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Chapter 2 (Part 2)
Chapter 2 (Part 2) Chapter 2 (Part 2)
Chapter 2 (Part 2)
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 
Runtime performance evaluation of embedded software
Runtime performance evaluation of embedded softwareRuntime performance evaluation of embedded software
Runtime performance evaluation of embedded software
 
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02
Runtimeperformanceevaluationofembeddedsoftware 100825224539-phpapp02
 
OS - Process Concepts
OS - Process ConceptsOS - Process Concepts
OS - Process Concepts
 
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdfWrite a program in C or C++ which simulates CPU scheduling in an opera.pdf
Write a program in C or C++ which simulates CPU scheduling in an opera.pdf
 
UNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdfUNIT - 3 PPT(Part- 1)_.pdf
UNIT - 3 PPT(Part- 1)_.pdf
 
Operating system Q/A
Operating system Q/AOperating system Q/A
Operating system Q/A
 
Ch7 OS
Ch7 OSCh7 OS
Ch7 OS
 
Operating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - EngineeringOperating Systems Unit Two - Fourth Semester - Engineering
Operating Systems Unit Two - Fourth Semester - Engineering
 
Process management
Process managementProcess management
Process management
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
Operating System
Operating SystemOperating System
Operating System
 
Process management
Process managementProcess management
Process management
 
Os notes
Os notesOs notes
Os notes
 

More from festockton

Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docx
Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docxLearning ResourcesRequired ReadingsToseland, R. W., & Ri.docx
Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docxfestockton
 
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docx
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docxLeamosEscribamos Completa el párrafo con las formas correctas de lo.docx
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docxfestockton
 
Leadership via vision is necessary for success. Discuss in detail .docx
Leadership via vision is necessary for success. Discuss in detail .docxLeadership via vision is necessary for success. Discuss in detail .docx
Leadership via vision is necessary for success. Discuss in detail .docxfestockton
 
Learning about Language by Observing and ListeningThe real.docx
Learning about Language by Observing and ListeningThe real.docxLearning about Language by Observing and ListeningThe real.docx
Learning about Language by Observing and ListeningThe real.docxfestockton
 
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docx
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docxLearning Accomplishment Profile-Diagnostic Spanish Language Edit.docx
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docxfestockton
 
Learning about Language by Observing and ListeningThe real voy.docx
Learning about Language by Observing and ListeningThe real voy.docxLearning about Language by Observing and ListeningThe real voy.docx
Learning about Language by Observing and ListeningThe real voy.docxfestockton
 
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docx
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docxLEARNING OUTCOMES1. Have knowledge and understanding of the pri.docx
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docxfestockton
 
Leadership Style What do people do when they are leadingAssignme.docx
Leadership Style What do people do when they are leadingAssignme.docxLeadership Style What do people do when they are leadingAssignme.docx
Leadership Style What do people do when they are leadingAssignme.docxfestockton
 
Leadership Throughout HistoryHistory is filled with tales of leade.docx
Leadership Throughout HistoryHistory is filled with tales of leade.docxLeadership Throughout HistoryHistory is filled with tales of leade.docx
Leadership Throughout HistoryHistory is filled with tales of leade.docxfestockton
 
Lean Inventory Management1. Why do you think lean inventory manage.docx
Lean Inventory Management1. Why do you think lean inventory manage.docxLean Inventory Management1. Why do you think lean inventory manage.docx
Lean Inventory Management1. Why do you think lean inventory manage.docxfestockton
 
Leadership varies widely by culture and personality. An internationa.docx
Leadership varies widely by culture and personality. An internationa.docxLeadership varies widely by culture and personality. An internationa.docx
Leadership varies widely by culture and personality. An internationa.docxfestockton
 
Leadership is the ability to influence people toward the attainment .docx
Leadership is the ability to influence people toward the attainment .docxLeadership is the ability to influence people toward the attainment .docx
Leadership is the ability to influence people toward the attainment .docxfestockton
 
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docx
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docxLawday. Court of Brightwaltham holden on Monday next after Ascension.docx
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docxfestockton
 
law43665_fm_i-xx i 010719 1032 AMStakeholders, Eth.docx
law43665_fm_i-xx i 010719  1032 AMStakeholders, Eth.docxlaw43665_fm_i-xx i 010719  1032 AMStakeholders, Eth.docx
law43665_fm_i-xx i 010719 1032 AMStakeholders, Eth.docxfestockton
 
Leaders face many hurdles when leading in multiple countries. There .docx
Leaders face many hurdles when leading in multiple countries. There .docxLeaders face many hurdles when leading in multiple countries. There .docx
Leaders face many hurdles when leading in multiple countries. There .docxfestockton
 
Last year Angelina Jolie had a double mastectomy because of re.docx
Last year Angelina Jolie had a double mastectomy because of re.docxLast year Angelina Jolie had a double mastectomy because of re.docx
Last year Angelina Jolie had a double mastectomy because of re.docxfestockton
 
Leaders face many hurdles when leading in multiple countries. Ther.docx
Leaders face many hurdles when leading in multiple countries. Ther.docxLeaders face many hurdles when leading in multiple countries. Ther.docx
Leaders face many hurdles when leading in multiple countries. Ther.docxfestockton
 
Leaders today must be able to create a compelling vision for the org.docx
Leaders today must be able to create a compelling vision for the org.docxLeaders today must be able to create a compelling vision for the org.docx
Leaders today must be able to create a compelling vision for the org.docxfestockton
 
Law enforcement professionals and investigators use digital fore.docx
Law enforcement professionals and investigators use digital fore.docxLaw enforcement professionals and investigators use digital fore.docx
Law enforcement professionals and investigators use digital fore.docxfestockton
 
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docx
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docxLAW and Economics 4 questionsLaw And EconomicsTextsCoote.docx
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docxfestockton
 

More from festockton (20)

Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docx
Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docxLearning ResourcesRequired ReadingsToseland, R. W., & Ri.docx
Learning ResourcesRequired ReadingsToseland, R. W., & Ri.docx
 
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docx
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docxLeamosEscribamos Completa el párrafo con las formas correctas de lo.docx
LeamosEscribamos Completa el párrafo con las formas correctas de lo.docx
 
Leadership via vision is necessary for success. Discuss in detail .docx
Leadership via vision is necessary for success. Discuss in detail .docxLeadership via vision is necessary for success. Discuss in detail .docx
Leadership via vision is necessary for success. Discuss in detail .docx
 
Learning about Language by Observing and ListeningThe real.docx
Learning about Language by Observing and ListeningThe real.docxLearning about Language by Observing and ListeningThe real.docx
Learning about Language by Observing and ListeningThe real.docx
 
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docx
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docxLearning Accomplishment Profile-Diagnostic Spanish Language Edit.docx
Learning Accomplishment Profile-Diagnostic Spanish Language Edit.docx
 
Learning about Language by Observing and ListeningThe real voy.docx
Learning about Language by Observing and ListeningThe real voy.docxLearning about Language by Observing and ListeningThe real voy.docx
Learning about Language by Observing and ListeningThe real voy.docx
 
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docx
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docxLEARNING OUTCOMES1. Have knowledge and understanding of the pri.docx
LEARNING OUTCOMES1. Have knowledge and understanding of the pri.docx
 
Leadership Style What do people do when they are leadingAssignme.docx
Leadership Style What do people do when they are leadingAssignme.docxLeadership Style What do people do when they are leadingAssignme.docx
Leadership Style What do people do when they are leadingAssignme.docx
 
Leadership Throughout HistoryHistory is filled with tales of leade.docx
Leadership Throughout HistoryHistory is filled with tales of leade.docxLeadership Throughout HistoryHistory is filled with tales of leade.docx
Leadership Throughout HistoryHistory is filled with tales of leade.docx
 
Lean Inventory Management1. Why do you think lean inventory manage.docx
Lean Inventory Management1. Why do you think lean inventory manage.docxLean Inventory Management1. Why do you think lean inventory manage.docx
Lean Inventory Management1. Why do you think lean inventory manage.docx
 
Leadership varies widely by culture and personality. An internationa.docx
Leadership varies widely by culture and personality. An internationa.docxLeadership varies widely by culture and personality. An internationa.docx
Leadership varies widely by culture and personality. An internationa.docx
 
Leadership is the ability to influence people toward the attainment .docx
Leadership is the ability to influence people toward the attainment .docxLeadership is the ability to influence people toward the attainment .docx
Leadership is the ability to influence people toward the attainment .docx
 
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docx
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docxLawday. Court of Brightwaltham holden on Monday next after Ascension.docx
Lawday. Court of Brightwaltham holden on Monday next after Ascension.docx
 
law43665_fm_i-xx i 010719 1032 AMStakeholders, Eth.docx
law43665_fm_i-xx i 010719  1032 AMStakeholders, Eth.docxlaw43665_fm_i-xx i 010719  1032 AMStakeholders, Eth.docx
law43665_fm_i-xx i 010719 1032 AMStakeholders, Eth.docx
 
Leaders face many hurdles when leading in multiple countries. There .docx
Leaders face many hurdles when leading in multiple countries. There .docxLeaders face many hurdles when leading in multiple countries. There .docx
Leaders face many hurdles when leading in multiple countries. There .docx
 
Last year Angelina Jolie had a double mastectomy because of re.docx
Last year Angelina Jolie had a double mastectomy because of re.docxLast year Angelina Jolie had a double mastectomy because of re.docx
Last year Angelina Jolie had a double mastectomy because of re.docx
 
Leaders face many hurdles when leading in multiple countries. Ther.docx
Leaders face many hurdles when leading in multiple countries. Ther.docxLeaders face many hurdles when leading in multiple countries. Ther.docx
Leaders face many hurdles when leading in multiple countries. Ther.docx
 
Leaders today must be able to create a compelling vision for the org.docx
Leaders today must be able to create a compelling vision for the org.docxLeaders today must be able to create a compelling vision for the org.docx
Leaders today must be able to create a compelling vision for the org.docx
 
Law enforcement professionals and investigators use digital fore.docx
Law enforcement professionals and investigators use digital fore.docxLaw enforcement professionals and investigators use digital fore.docx
Law enforcement professionals and investigators use digital fore.docx
 
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docx
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docxLAW and Economics 4 questionsLaw And EconomicsTextsCoote.docx
LAW and Economics 4 questionsLaw And EconomicsTextsCoote.docx
 

Recently uploaded

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 

Recently uploaded (20)

Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 

Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx

  • 1. Lab 3 of 7: Process Management Simulation L A B O V E R V I E W Scenario/Summary Process Management Simulation (Part 3 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, and 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 image and process 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
  • 2. , 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. 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. Command T can 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
  • 3. 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. D n: 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. F n: 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. R 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 process is as follows: S 1000 A 19
  • 4. 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 , and process 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 the F instruction (read from the simulated processes).
  • 5. 2.1 Data structures: The process manager maintains six data structures: Time, Cpu, PcbTable, ReadyState, BlockedState, and RunningState . Time is an integer variable initialized to zero. Cpu is used to simulate the execution of a simulated process that is in running state. It should include data members to store a pointer to the program array, current program counter value, integer value, and time slice of that simulated process. In addition, it should store the number of time units used so far in the current time slice. PcbTable is an array with one entry for every simulated process that hasn't finished its execution yet. Each entry should include data members to store process ID, parent process ID, a pointer to program counter value (initially 0), integer value, priority, state, start time, and CPU time used so far. ReadyState stores all simulated processes (PcbTable indices) that are ready to run. This can be implemented using a queue or priority queue data structure. BlockedState stores all processes (PcbTable indices) that are currently blocked. This can be implemented using a queue data structure. RunningState stores the PcbTable index of the currently running simulated process. 2.2 Processing input commands: After creating the first process and initializing all its data structures, the process manager repeatedly receives and
  • 6. processes one command at a time from the commander process (read via the pipe). On receiving a Q command, the process manager executes the next instruction of the currently running simulated process, increments program counter value (except for F or R instructions), increments Time , and then performs scheduling. Note that scheduling may involve performing context switching. On receiving a U command, the process manager moves the first simulated process in the blocked queue to the ready state queue array. On receiving a P command, the process manager spawns a new reporter process. On receiving a T command, 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 a Q command from the commander process. Note that this execution is completely confined to the Cpu data structure, i.e., PcbTable is not accessed.
  • 7. Instructions S , A, and D update the integer value stored in Cpu . Instruction B moves 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. Instruction E terminates the currently running simulated process, frees up all memory (e.g., program array) associated with that process and updates the PcbTable . A simulated process from the ready state is moved to running state. This also results in a context switch. Instruction F results in the creation of a new simulated process. A new entry is created in the PcbTable for this new simulated process. A new (unique) process ID is assigned and the parent process ID is the process ID of the parent simulated process. Start time is set to the current Time value 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 the F
  • 8. instruction, while the program counter value of the of the parent simulated process is set to n instructions after the next instruction (instruction immediately after F ). The new simulated process is created in the ready state. Finally, the R instruction results in replacing the process image of the currently running simulated process. Its program array is overwritten by the code in file filename , program counter value is set to 0, and integer value is undefined. Note that all these changes are made only in the Cpu data 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: *****************************************************
  • 9. *********** 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 three separate files to the dropbox for Week 3: C or C++ program (source code) Executable file (object), and Instructions to execute the program L A B S T E P S Process Manager Scheduling (25 points)
  • 10. The programs for the process scheduling and the reporter process are due this week. These programs are to be written in C or C++ programming languages on a Linux environment. IMPORTANT: Please make sure that any questions or clarification about these labs are addressed early. 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. Reporter Process Requirements (25 points) 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:
  • 11. 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 ***************************************************** ***********