SlideShare a Scribd company logo
1 of 22
ECET 360 Hands On Exercise 4
For more classes visit
www.snaptutorial.com
Advanced C Programming
You are required to study and understand the under lying concepts of
advanced C used in the examples below. You are also required to
compile and execute the programs and capture the output generated by
each program
1. A Simple C program with more than one function (Parameters passed
by value)
2. Basic concepts of Pointers in C
The following program demonstrates about the pointer variable, * and &
operators.
3. Passing parameters to function by pointers
4. Using Structures in C
5. Structures
Structure is a collection / group of different / same variables.
Example:
**********************************************************
ECET 360 Hands On Exercise 5
For more classes visit
www.snaptutorial.com
Objective:
This hands on exercise examines aspects of threads and multiprocessing
(and multithreading). The primary objective of this exercise is to
implement the Thread Management Functions:
Creating Threads
Terminating Thread Execution
Thread Identifiers
Joining Threads
Detaching / Undetaching Threads
**********************************************************
ECET 360 Hands On Exercise 7
For more classes visit
www.snaptutorial.com
Objectives:
In this hands on exercise, we will use semaphore to solve various
synchronization problems. Semaphores are counters for resources
shared between processes/threads. The basic operations on semaphores
are: increment the counter atomically, and wait until the counter is non-
null and decrement it atomically.
This exercise has two primary objectives:
How to use semaphore to solve various synchronization problems
Implementing the POSIX.1b semaphore functions which include
™ Initializing semaphores
™ Decreasing the count of a semaphore.
™ Increasing the count of a semaphore.
™ Destroying semaphores.
**********************************************************
ECET 360 Week 2 iLab
For more classes visit
www.snaptutorial.com
Accessing Your Lab
To access your labs after you've logged in, apply the following steps:
Click the Professional Development tab located on the top of the page.
Select "Development Paths".
You will see the course that you are taking listed on this page.
Click the course to see the labs.
Starting Your Lab
There are two ways to start a lab activity:
Schedule It. (Recommended)
Because you have access to live equipment, there is only a defined
number of students who can use any one lab at any given time. It is
recommended to schedule your labs to make sure the lab is available to
you at your convenience. If you try to log into a lab and the access is
denied, the system will let you schedule the lab at a later date.
Start it right away.
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 image andprocess 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.
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, 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 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 Qcommand 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. InstructionEterminates 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 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 Finstruction, 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 to the dropbox, for week 2, three separate files:
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 (50 points)
The program for the process manager functions: process creation,
replacing the current process image with a new process image and
process state transition, are due this 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 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 Qcommand 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. InstructionEterminates 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 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 Finstruction, 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.
1.1 Simulated Process:
Additional Information for the Process Manager:
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.
**********************************************************
ECET 360 Week 4 iLab
For more classes visit
www.snaptutorial.com
The objective of this week's lab is to simulate and evaluate different
memory allocation/deallocation techniques (first fit,next fit, best fit, and
worst fit)when a linked list is used to keep track of memory usage.You
will implement a separate Memory component for TWO of the four
memory allocation/deallocation techniques. This lab is designed to be
completed in two weeks. One allocation/deallocation technique is due on
Week 4, and the second technique is due on Week 5.Assume that the
memory is 256 KB and is divided into units of 2 KB each. A process
may request between 3 and 10 units of memory. Your simulation
consists of three components: a Memorycomponent that implements a
specific allocation/deallocation technique, arequest generation
component that generates allocation/deallocation requests, and a
statisticsreportingcomponent that prints out the relevant statistics. The
Memory component exports the following functions:
int allocate_mem(int process_id, int num_units): allocates num_units
units of memory to a process whose id is process_id. If successful, it
returns the number of nodes traversed in the linked list. Otherwise, it
returns -1.
int deallocate_mem(int process_id): deallocates the memory allocated to
the process whose ID is process_id. It returns 1, if successful, otherwise
“1.
int fragment_count( ): returns the number of holes (fragments of sizes 1
or 2 units).
The request generation component generates allocation and deallocation
requests. For allocation requests, the component specifies the process ID
of the process for which memory is requested as well as the number of
memory units being requested. For this simulation, assume that memory
is requested for each process only once. For deallocation requests, the
component specifies the process ID of the process whose memory has to
be deallocated. For this simulation, assume that the entire memory
allocated to a process is deallocated on a deallocation request. You may
generate these requests based on some specific criteria, e.g., at random
or from a memory allocation/deallocation trace obtained from some
source.
There are three performance parameters that your simulation should
calculate for the chosen two techniques: average number of external
fragments, average allocation time in terms of the average number of
nodes traversed in allocation, and the percentage of times an allocation
request is denied.
Generate 10,000 requests using the request generation component, and
for each request, invoke the appropriate function of the Memory
component for each of the memory allocation/deallocation techniques.
After every request, update the three performance parameters for each of
the techniques. The statistics reporting component prints the value of the
three parameters for the two techniques at the end.
You will submit four separate files to the dropbox for Week 4:
C or C++ program (source code)
Executable file (object)
Instructions to execute the program
Analysis of the results for the chosen allocation/deallocation technique
**********************************************************
ECET 360 Week 5 Lab Memory Management II
For more classes visit
www.snaptutorial.com
Objective
To write a C program to implement memory management using
segmentation.
ALGORITHM:
Step1 : Start the program.
Step2 : Read the base address, number of segments, size of each
segment, memory limit.
Step3 : If memory address is less than the base address display “invalid
memory limit”.
Step4 : Create the segment table with the segment number and segment
address and display it.
Step5 : Read the segment number and displacement.
Step6 : If the segment number and displacement is valid compute the
real address and display the same.
Step7 : Stop the program
**********************************************************
ECET 360 Week 6 and 7 Lab
For more classes visit
www.snaptutorial.com
Write a C program to simulate the shortest job first algorithm with
preemption.
DESCRIPTION:
For implementing SJF algorithm with preemption, we consider the
arrival
times of each process, the burst times of all the previously arrived
processes.
After the arrival of all the processes into the ready queue, the average
waiting
time and turn around time can be calculated by using the above
algorithm.
**********************************************************

More Related Content

What's hot

SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)Amr E. Mohamed
 
Real-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsReal-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsAJAL A J
 
Uvm presentation dac2011_final
Uvm presentation dac2011_finalUvm presentation dac2011_final
Uvm presentation dac2011_finalsean chen
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimizationKarthik Vivek
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2Techglyphs
 
Operating system 23 process synchronization
Operating system 23 process synchronizationOperating system 23 process synchronization
Operating system 23 process synchronizationVaibhav Khanna
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution立偉 馬
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process SynchronizationShipra Swati
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating SystemsRitu Ranjan Shrivastwa
 
Command Line Arguments in C#
Command Line Arguments in C#Command Line Arguments in C#
Command Line Arguments in C#Ali Hassan
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksMukesh Chinta
 
Unit Testing in PHP
Unit Testing in PHPUnit Testing in PHP
Unit Testing in PHPRadu Murzea
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)IJERD Editor
 

What's hot (18)

SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)SE2018_Lec 20_ Test-Driven Development (TDD)
SE2018_Lec 20_ Test-Driven Development (TDD)
 
Real-Time Scheduling Algorithms
Real-Time Scheduling AlgorithmsReal-Time Scheduling Algorithms
Real-Time Scheduling Algorithms
 
Final Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answersFinal Exam OS fall 2012-2013 with answers
Final Exam OS fall 2012-2013 with answers
 
Uvm presentation dac2011_final
Uvm presentation dac2011_finalUvm presentation dac2011_final
Uvm presentation dac2011_final
 
Compiler optimization
Compiler optimizationCompiler optimization
Compiler optimization
 
Bt0081 software engineering2
Bt0081 software engineering2Bt0081 software engineering2
Bt0081 software engineering2
 
Operating system 23 process synchronization
Operating system 23 process synchronizationOperating system 23 process synchronization
Operating system 23 process synchronization
 
A Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process ExecutionA Scripting Environment for Refactoring Process Execution
A Scripting Environment for Refactoring Process Execution
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 
Process synchronization in Operating Systems
Process synchronization in Operating SystemsProcess synchronization in Operating Systems
Process synchronization in Operating Systems
 
process creation OS
process creation OSprocess creation OS
process creation OS
 
Command Line Arguments in C#
Command Line Arguments in C#Command Line Arguments in C#
Command Line Arguments in C#
 
Jonathan bromley doulos
Jonathan bromley doulosJonathan bromley doulos
Jonathan bromley doulos
 
Operating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and DeadlocksOperating Systems - Process Synchronization and Deadlocks
Operating Systems - Process Synchronization and Deadlocks
 
Unit Testing in PHP
Unit Testing in PHPUnit Testing in PHP
Unit Testing in PHP
 
Java multi thread programming on cmp system
Java multi thread programming on cmp systemJava multi thread programming on cmp system
Java multi thread programming on cmp system
 
OSCh7
OSCh7OSCh7
OSCh7
 
International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)International Journal of Engineering Research and Development (IJERD)
International Journal of Engineering Research and Development (IJERD)
 

Similar to Ecet 360 Success Begins / snaptutorial.com

ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorialpinck2380
 
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docxLab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docxfestockton
 
Operator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxOperator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxcherishwinsland
 
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.docxstilliegeorgiana
 
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
 
Assignment 02 Process State SimulationCSci 430 Introduction to.docx
Assignment 02 Process State SimulationCSci 430 Introduction to.docxAssignment 02 Process State SimulationCSci 430 Introduction to.docx
Assignment 02 Process State SimulationCSci 430 Introduction to.docxcargillfilberto
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxpbilly1
 
SMP4 Thread Scheduler (PART 1)======================INSTR.docx
SMP4 Thread Scheduler (PART 1)======================INSTR.docxSMP4 Thread Scheduler (PART 1)======================INSTR.docx
SMP4 Thread Scheduler (PART 1)======================INSTR.docxpbilly1
 
SMP4 Thread Scheduler (PART 1)======================INS.docx
SMP4 Thread Scheduler (PART 1)======================INS.docxSMP4 Thread Scheduler (PART 1)======================INS.docx
SMP4 Thread Scheduler (PART 1)======================INS.docxpbilly1
 
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
 
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
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG Greg.Helton
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - IntroductionTo Sum It Up
 

Similar to Ecet 360 Success Begins / snaptutorial.com (20)

ECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/SnaptutorialECET 360 help A Guide to career/Snaptutorial
ECET 360 help A Guide to career/Snaptutorial
 
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docxLab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
Lab 3 of 7 Process Management Simulation L A B  O V E R V I E W.docx
 
Operator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.docxOperator Instructions Once the program is running the operator c.docx
Operator Instructions Once the program is running the operator c.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.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.docx
 
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docxSheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
Sheet1Address60741024Offsetaddress0102450506074120484026230723002p.docx
 
Experimentos lab
Experimentos labExperimentos lab
Experimentos lab
 
Assignment 02 Process State SimulationCSci 430 Introduction to.docx
Assignment 02 Process State SimulationCSci 430 Introduction to.docxAssignment 02 Process State SimulationCSci 430 Introduction to.docx
Assignment 02 Process State SimulationCSci 430 Introduction to.docx
 
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docxSMP4 Thread Scheduler======================INSTRUCTIONS.docx
SMP4 Thread Scheduler======================INSTRUCTIONS.docx
 
Lect 3-4 Zaheer Abbas
Lect 3-4 Zaheer AbbasLect 3-4 Zaheer Abbas
Lect 3-4 Zaheer Abbas
 
SMP4 Thread Scheduler (PART 1)======================INSTR.docx
SMP4 Thread Scheduler (PART 1)======================INSTR.docxSMP4 Thread Scheduler (PART 1)======================INSTR.docx
SMP4 Thread Scheduler (PART 1)======================INSTR.docx
 
SMP4 Thread Scheduler (PART 1)======================INS.docx
SMP4 Thread Scheduler (PART 1)======================INS.docxSMP4 Thread Scheduler (PART 1)======================INS.docx
SMP4 Thread Scheduler (PART 1)======================INS.docx
 
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
 
Operating system Q/A
Operating system Q/AOperating system Q/A
Operating system Q/A
 
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
 
RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG RPG Program for Unit Testing RPG
RPG Program for Unit Testing RPG
 
System Calls - Introduction
System Calls - IntroductionSystem Calls - Introduction
System Calls - Introduction
 
OS (1).pptx
OS (1).pptxOS (1).pptx
OS (1).pptx
 
Chapter 3.pdf
Chapter 3.pdfChapter 3.pdf
Chapter 3.pdf
 

Recently uploaded

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
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
“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
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 

Recently uploaded (20)

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,
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini 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...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 

Ecet 360 Success Begins / snaptutorial.com

  • 1. ECET 360 Hands On Exercise 4 For more classes visit www.snaptutorial.com Advanced C Programming You are required to study and understand the under lying concepts of advanced C used in the examples below. You are also required to compile and execute the programs and capture the output generated by each program 1. A Simple C program with more than one function (Parameters passed by value) 2. Basic concepts of Pointers in C The following program demonstrates about the pointer variable, * and & operators. 3. Passing parameters to function by pointers 4. Using Structures in C 5. Structures Structure is a collection / group of different / same variables. Example:
  • 2. ********************************************************** ECET 360 Hands On Exercise 5 For more classes visit www.snaptutorial.com Objective: This hands on exercise examines aspects of threads and multiprocessing (and multithreading). The primary objective of this exercise is to implement the Thread Management Functions: Creating Threads Terminating Thread Execution Thread Identifiers Joining Threads Detaching / Undetaching Threads **********************************************************
  • 3. ECET 360 Hands On Exercise 7 For more classes visit www.snaptutorial.com Objectives: In this hands on exercise, we will use semaphore to solve various synchronization problems. Semaphores are counters for resources shared between processes/threads. The basic operations on semaphores are: increment the counter atomically, and wait until the counter is non- null and decrement it atomically. This exercise has two primary objectives: How to use semaphore to solve various synchronization problems Implementing the POSIX.1b semaphore functions which include ™ Initializing semaphores ™ Decreasing the count of a semaphore. ™ Increasing the count of a semaphore. ™ Destroying semaphores. **********************************************************
  • 4. ECET 360 Week 2 iLab For more classes visit www.snaptutorial.com Accessing Your Lab To access your labs after you've logged in, apply the following steps: Click the Professional Development tab located on the top of the page. Select "Development Paths". You will see the course that you are taking listed on this page. Click the course to see the labs. Starting Your Lab There are two ways to start a lab activity: Schedule It. (Recommended) Because you have access to live equipment, there is only a defined number of students who can use any one lab at any given time. It is recommended to schedule your labs to make sure the lab is available to you at your convenience. If you try to log into a lab and the access is denied, the system will let you schedule the lab at a later date.
  • 5. Start it right away. 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 image andprocess 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
  • 6. 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)
  • 7. 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
  • 8. 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 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
  • 9. 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.
  • 10. 2.3 Executing simulated processes: The process manager executes the next instruction of the currently running simulated process on receiving a Qcommand 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. InstructionEterminates 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 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 Finstruction, 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
  • 11. 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:
  • 12. 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: 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 (50 points) The program for the process manager functions: process creation, replacing the current process image with a new process image and process state transition, are due this week. This program is to be written in C or C++ programming languages on a Linux environment.
  • 13. 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 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
  • 14. 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:
  • 15. The process manager executes the next instruction of the currently running simulated process on receiving a Qcommand 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. InstructionEterminates 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 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 Finstruction, 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
  • 16. data structure. Process id, parent process id, start time, CPU time used so far, state, and priority remain unchanged. 1.1 Simulated Process: Additional Information for the Process Manager: 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.
  • 17. 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. **********************************************************
  • 18. ECET 360 Week 4 iLab For more classes visit www.snaptutorial.com The objective of this week's lab is to simulate and evaluate different memory allocation/deallocation techniques (first fit,next fit, best fit, and worst fit)when a linked list is used to keep track of memory usage.You will implement a separate Memory component for TWO of the four memory allocation/deallocation techniques. This lab is designed to be completed in two weeks. One allocation/deallocation technique is due on Week 4, and the second technique is due on Week 5.Assume that the memory is 256 KB and is divided into units of 2 KB each. A process may request between 3 and 10 units of memory. Your simulation consists of three components: a Memorycomponent that implements a specific allocation/deallocation technique, arequest generation component that generates allocation/deallocation requests, and a statisticsreportingcomponent that prints out the relevant statistics. The Memory component exports the following functions: int allocate_mem(int process_id, int num_units): allocates num_units units of memory to a process whose id is process_id. If successful, it returns the number of nodes traversed in the linked list. Otherwise, it returns -1.
  • 19. int deallocate_mem(int process_id): deallocates the memory allocated to the process whose ID is process_id. It returns 1, if successful, otherwise “1. int fragment_count( ): returns the number of holes (fragments of sizes 1 or 2 units). The request generation component generates allocation and deallocation requests. For allocation requests, the component specifies the process ID of the process for which memory is requested as well as the number of memory units being requested. For this simulation, assume that memory is requested for each process only once. For deallocation requests, the component specifies the process ID of the process whose memory has to be deallocated. For this simulation, assume that the entire memory allocated to a process is deallocated on a deallocation request. You may generate these requests based on some specific criteria, e.g., at random or from a memory allocation/deallocation trace obtained from some source. There are three performance parameters that your simulation should calculate for the chosen two techniques: average number of external fragments, average allocation time in terms of the average number of nodes traversed in allocation, and the percentage of times an allocation request is denied. Generate 10,000 requests using the request generation component, and for each request, invoke the appropriate function of the Memory component for each of the memory allocation/deallocation techniques. After every request, update the three performance parameters for each of the techniques. The statistics reporting component prints the value of the three parameters for the two techniques at the end. You will submit four separate files to the dropbox for Week 4:
  • 20. C or C++ program (source code) Executable file (object) Instructions to execute the program Analysis of the results for the chosen allocation/deallocation technique ********************************************************** ECET 360 Week 5 Lab Memory Management II For more classes visit www.snaptutorial.com Objective To write a C program to implement memory management using segmentation. ALGORITHM: Step1 : Start the program. Step2 : Read the base address, number of segments, size of each segment, memory limit.
  • 21. Step3 : If memory address is less than the base address display “invalid memory limit”. Step4 : Create the segment table with the segment number and segment address and display it. Step5 : Read the segment number and displacement. Step6 : If the segment number and displacement is valid compute the real address and display the same. Step7 : Stop the program ********************************************************** ECET 360 Week 6 and 7 Lab For more classes visit www.snaptutorial.com Write a C program to simulate the shortest job first algorithm with preemption. DESCRIPTION: For implementing SJF algorithm with preemption, we consider the arrival
  • 22. times of each process, the burst times of all the previously arrived processes. After the arrival of all the processes into the ready queue, the average waiting time and turn around time can be calculated by using the above algorithm. **********************************************************