UNIVERSITY OF DAR ES SALAAM
COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY.
COURSE: PRINCIPLES OF OPERATING SYTEMS (CS334)
ASSIGNMENT NAME: IMPLEMENTATION OF PROGRAM
SCHEDULING
GROUP 19 MEMBERS
NAME REGISTRATION NUMBER
ANDREW B. SANDY 2022-04-11903
AHMED ABDULLAH 2022-04-00089
SABRA SEIF 2022-04-12051
KAUTHAR YUSUF 2022-04-13449
REGINA MWIGUNE 2022-04-13605
MWAJUMA Y. SALUM 2022-04-11798
ELISHA DANIEL 2022-04-01450
HUBERT BAHATI 2022-04-00613
EMMANUEL MAGANGA 2022-04-05599
GLADNESS MATHEW 2022-04-06637
1. IMPLEMENTATION OF PROGRAM SCHEDULING 1
OBJECTIVES:
Explain what software simulators can do
Use an operating system simulator
Use the simulator to demonstrate different scheduling policies
Explain what threads are and how they are created
SIMULATOR-BASED EXERCISES
Loading program and Creating processes
• [Link] was loaded into the simulator.
• CREATE PROCESS button was clicked.
Can you explain the result of the last action?
- The process FORNEXTLOOP was created and was scheduled in the READY
PROCESSES (Ready queue).
Running processes
• START button was clicked, located in the Control view
Can you explain what happened?
- The process was dispatched to the CPU as a RUNNING PROCESS, lasting for
12.376 seconds before it was successfully terminated.
What kind of information is displayed about a process?
- Once a process is created, it is first placed in the Ready queue and then is
dispatched to the CPU as a Running process until its terminated releasing
all the resources it was utilizing. (It may have completed its task
successfully or may have undergone other factors that may cause its
termination i.e. Interruption)
Operating system log
What sort of information is displayed by the log?
- Change of state of the process
- Scheduling scheme and memory allocation policy
- Time statistics of the process (i.e. Burst time, elapsed time etc.)
Investigating different scheduling policies
What is an algorithm?
- A computer program that dictates or guides the sequence of execution of
processes of a loaded programs.
• First-Come, First -Served (FCFS) policy was implemented
• Two processes were created
• CPU speed was set up to Fast position
• The scheduler was started
• All processes terminated normally
Explain the behavior of First-Come-First-Serve (FCFS) policy.
- It takes processes in sequential order from the first to last within the Ready
Queue and dispatches them to the CPU as a Running Process.
• Shortest Job First was implemented
• Priority (non-preemptive) was selected
Explain the behavior of Priority (Non-Preemptive) policy.
- It does not interrupt any of the process that proceeds the sequence of Priority
3,2,3,4 as how the order of processes was created.
• Round-Robin policy was implemented
• 10 ticks was set as the time slot
• The Scheduler was started
• The SUSPEND button was clicked after a short period of time after starting the
scheduler (approximately 2.6 seconds.)
• SHOW PCB button was clicked in the Ready Processes view
What do you see on the PCB view?
- PCB information section
- Program stack
- Register Set
Observe the number against the PC Register. What is the significance of this
number?
- The number is 0.
- It points to the Register that holds the first instruction being executed.
What other important information do you see about this process in the displayed
window?
- Resource status (Requested, Allocated, Starved)
- PCB history
• RESUME button was clicked
• All processes were left to terminate normally.
Explain the behavior of Round Robin policy.
- It executes each process for a designated time of 10 ticks in 0.2 seconds
before sending it back to the Ready queue taking in the next process.
• Priority (pre-emptive) was selected
• CPU speed was set up to near Slow position
• Two processes were created: one with a priority of 2 and the other with a priority of 3
• The scheduler was started
• Then, we created another process with a priority of 1
Which process is running?
- Process with priority 1
Which processes are in the ready queue?
- Process with priority 2
- Process with priority 3
Explain the behavior of Priority (Pre-emptive) policy.
- It takes the process with the highest priority first, even interrupting running
processes of lower priority.
• All processes were left to terminate normally.
• First-Come, First-Serve Policy was implemented
• Two processes were created
• CPU speed was set up to Fast position
• The Scheduler was started
• In the RUNNING PROCESSES, a Waiting Time of 10 seconds was set up and the
WAIT button was clicked.
Explain the behavior of this process.
- The running process is moved from the running process to the waiting queue
and waits there for 10 seconds while the other process is dispatched to the
CPU.
- After the 10 seconds, the process is sent to the ready queue waiting for the
other process to complete before its dispatched back to the CPU to be
successfully processed and terminated.
What state transitions did it go through?
- Ready>Running>Waiting>Ready>Running>Terminated.
2. IMPLEMENTATION OF PROGRAM SCHEDULING 2
OBJECTIVES:
Enter source code in the compiler and compile it
Load the generated code in the CPU simulator’s memory
Create processes from programs in the OS simulator
Select different scheduling policies and run the processes in the OS simulator.
Explain the differences between pre-emptive and non-pre-emptive scheduling.
Locate the PC Register value in a process’s PCB when it is in the ready queue.
Explain how the PC Register value in PCB is used when in Round Robin
scheduling.
LAB EXERICES – Investigate and Explore:
The CPU simulator was started and we created the first executable code (LOOPTEST) using the
compiler, a system delivered by the simulator, and was loaded to memory ready to be executed
as a process.
Figure 1: Executable code that’s compiled to LOOPTEST
Observation 1:
- 4 processes were made of LOOPTEST program
- First-Come, First-Serve Policy was implemented
- CPU speed set at Fastest position
Ans:
Processes were executed in the order they were created, with each being executed
entirely and were not interrupted nor switched.
Observation 2:
- Shortest Job First and Priority (Static) were implemented
- Non-preemptive
- 3 processes of priority 3,2,4 respectively were created
- CPU speed set at halfway position
- While first process was running, we created another process with Priority 1
- Then, CPU speed was pushed to Fastest position and waited for the processes to complete
Ans:
Processes were executed in the order they were created, with each being executed
entirely and were not interrupted nor switched.
Observation 3:
- Shortest Job First and Priority (Static) were implemented
- Pre-emptive
- 3 processes of priority 3,2,4 respectively was created
- CPU speed set at Halfway position
- While first process was running, we created another process with Priority 1
- Then, CPU speed was pushed to Fastest position and waited for the processes to complete
Ans:
Processes were executed in the order they were created, with each being executed
entirely and were not interrupted nor switched.
Observation 4:
- Round-Robin policy was implemented
- Non-preemptive
- 4 processes were created
Ans:
It followed the order the processes were created, with each process running for 5
ticks/time slot of 0.2 seconds and its sent back to the ready queue to execute the next
process
This procedure went on until all process were executed to completion
Observation 5:
- Round-Robin policy was implemented
- Non-preemptive
- We loaded a new source code to the compiler to create executable code using the
compiler
Figure 2: Executable code that’s compiled to LOOPTESTFOREVERTEST
- Created 3 processes with the following lifetimes respectively: 10 seconds (P1), 32
seconds (P2) and 6 seconds (P3).
- A time slot of 4 seconds was put for each process to run.
Ans:
The processes were executed in order of creation each using 4 seconds time slot
of processing before being sent back to ready queue for the next process to be
executed.
The process with the shortest lifetime was first to be terminated (P3), following
this order until the process of longest lifetime was terminated last (P2).
Statistics:
o P3: Elapsed time=15.51 seconds
Avg waiting time=1.07 seconds
o P2: Elapsed time=23.93 seconds
Avg waiting time=0.83 seconds
o P1: Elapsed time=50.70 seconds
Avg waiting time=0.83 seconds
Observation 6:
- Round-Robin policy was implemented
- Non-preemptive
- We loaded a new source code to the compiler to create executable code using the
compiler
Figure 3: Executable code that’s compiled to LOOPTESTFOREVERTEST2
- A single process for each program were created (In the order that they are written):
LOOPFOREVERTEST (P2) and LOOPFOREVERTEST2 (P3)
- The time Slice was 10 ticks
- CPU speed was set at Halfway position
- No instruction pipeline check-box was checked
- Suspend on Run was selected on the RUNNING PROCESSES
Ans:
Initial PC register numbers for:
P2- 0
P3- 0
After P2 was put back to ready queue after its initial execution:
P2 PC register- 17
P2 had a continual change in PC register number value during execution
following this pattern: 17, 21, 26, 32, 37, 42, 11, 17, 21, 26… repeatedly until its
successively executed
P3 had a continual change in PC register number value during execution
following this pattern: 0, 6, ,15, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 72, 77, 82,
0, 6, 10…. Repeatedly until its successively executed.