Overview

139 views 11:21 am 0 Comments June 27, 2023

Lab 4 (Week 6) Process Scheduling (II)

Overview

This lab is to be continuous from the last week lab (Lab 3) using the Process Scheduling Simulator.

Download the Process Scheduling simulator from LearnJCU and extract the zip file (ps.zip). This produces a folder named ps. The user manual for this simulator, ps_doc.html, is included in the folder. It is strongly suggested that you carefully read through this documentation describing how the simulator operates prior to beginning this section. It is also recommended that you complete the previous lab (Lab 3) as well.


In the
ps directory, there are two files: (1) myrun.run (the run file); and (2) myexp.exp (the experiment file.) The run file specifies various parameters such as the number of processes, inter-arrival times, process duration (how long it requires the CPU), and the length of CPU and I/O bursts. The experiment file specifies the number of experiments that are to be run using the run file. Each experiment in the experiment file runs the scheduler according to the parameters specified in the run file. For example, if the experiment file myexp.exp contains the following:

name myexp
comment This experiment contains 2 runs
run myrun algorithm FCFS key “FCFS”
run myrun algorithm SJF key “SJF”


this means the experiment specifies two runs will be performed, one using FCFS scheduling, the other using SJF scheduling.

If the run file myrun.run contains:

name myrun
comment This run specifies one type of process
algorithm FCFS
seed 5000
numprocs 20
firstarrival 0.0
interarrival constant 0.0
duration constant 100
cpuburst constant 10
ioburst constant 10
basepriority 1.0


this means each experiment will run the scheduler with 20 processes, all arriving at time 0. The duration of each process is 100, and the CPU and I/O bursts are both constant at 10.


The user manual for this simulator,
ps_doc.html, fully explains the parameters for the experiment and run files. It is strongly suggested that you read through this manual before proceeding, as well as keep it open while performing the following exercises.

Exercise Tasks

Perform the following steps using the process scheduling simulator

Using a text editor, replace the contents of myexp.exp and myrun.run with the experiment and run files shown above. (Both the myexp.exp and myrun.run files are located in the ps directory.)

In the ps directory, execute runps(UNIX, Linux, Mac OS X) or runps.bat (Windows.) This will start the process scheduling simulator.

Click the Run Experiment button and then click the Show All Table Data button. Next, click the Draw Gantt Chart button, once for the FCFS, a second time for SJF.

<< Unless otherwise specified, set the value of myrun.run and myexp.exp back to the default values that are shown above. >>

———————————————————————————————–

Questions

Answer the following questions after completing Steps 1-3 above.

Examining the output from Step 3, you should be able to easily determine that the scheduling behavior was no different between the FCFS and SJF algorithms. Explain why.

Click the Run Experiment button, and then create a Gantt chart for the FCFS, and a second Gantt chart for the SJF. In both Gantt charts, the last process finishes at time 2000. Explain why.

Change the value of cpuburst in myrun.run from cpuburst constant 10 to cpuburst uniform 10 25. This has the affect of assigning CPU bursts randomly with values ranging from 10 to 25. Run the simulator with this changed parameter, and examine the Gantt charts for the FCFS and SJF. Do the FCFS and SJF algorithms schedule processes the same or differently?

In Section 5.3.1 of the text the convoy effect of FCFS scheduling is described. The following values of myrun.run specify two types of processes:

name myrun
comment This run specifies two types of processes
algorithm FCFS
seed 5000
numprocs 5
firstarrival 0.0
interarrival constant 0.0
duration constant 50
cpuburst uniform 1 5
ioburst constant 10
basepriority 1.0

numprocs 1
firstarrival 0.0
interarrival constant 0.0
duration constant 50
cpuburst constant 25
ioburst uniform 1 5
basepriority 1.0

The first type of process specifies 5 processes with a uniform CPU burst uniformly distributed between 1 and 5 and a constant I/O burst of 10. The second type of process is a single process with a constant CPU burst of 25, and a uniform I/O burst distributed between 1 and 5. Thus, there are 5 I/O-bound processes, and 1 CPU-bound process.


Change the value of
myrun.run as shown above. Run the simulator with this changed parameter, and examine the Gantt chart for the FCFS. What process(es) are part of the convoy the second time process 6 gets the CPU?


a) Processes 1 through 5
b) Processes 1 through 6
c) Processes 2 through 5
d) There is no convoy effect in this situation.

Change the value of myexp.exp to the following:

name myexp
comment This experiment contains 5 runs
run myrun algorithm FCFS key “FCFS”
run myrun algorithm SJF key “SJF”
run myrun algorithm RR 1 key “RR 1”
run myrun algorithm RR 5 key “RR 5”
run myrun algorithm RR 10 key “RR 10”


This specifies 5 different runs of the scheduler, FCFS and SJF are the first two. The next three are round-robin (RR) with time quantums of 1, 5, and 10, respectively.

Change the value of myrun.run to the following:

name myrun
comment This contains one type of process
algorithm SJF
seed 5000
numprocs 20
firstarrival 0.0
interarrival constant 0.0
duration constant 50
cpuburst uniform 2 20
ioburst constant 10
basepriority 1.0


In this run file, there are 20 processes with a constant duration and I/O burst. The CPU burst will uniformly range between 2 and 20.

Run the simulator with this changed parameter, and click the Show All Table Data button.

Which scheduling algorithm has most context switches?

a) FCFS
    b) RR 1
c) RR 5
d) RR 10

Draw the Gantt chart for both the FCFS and SJF algorithms. Notice they look quite different. Yet in the table, both FCFS and SJF have the same number of context switches (109). Explain why.

Preemptive SJF (PSJF) scheduling is discussed in Section 5.3.2 of the text. PSJF is the situation whereby, if a newly arrived process has a shorter next CPU burst than the currently executing processes, the newly arriving process will preempt the process currently running. (SJF scheduling has no such preemption.) Add the following line to myexp.exp:

run myrun algorithm PSJF key “PSJF”

which adds an experimental run using PSJF scheduling. Run the simulator again, and examine the Table Data.

What can be said about the relationship between the number of context switches for the SJF and PSJF scheduling algorithms?

a) They both have exactly the same number of context switches.
b) They both have approximately the same number of context switches.
c) SJF has more context switches.
d) PSJF has more context switches.

For the 3 RR scheduling runs, what can be said about average waiting time with an increasing time quantum?

a) Average waiting time increases with an increasing time quantum.
b) Average waiting time decreases with an increasing time quantum.
c) There is no correspondence between average waiting time and the length of the time quantum.

Section 5.3.4 of the text states that the performance of round-robin scheduling is heavily dependent upon the length of the time quantum. If the time quantum is large, the RR scheduling policy is the same as FCFS policy.

Assuming myrun.run  stays the same as shown above, which of the following lines need to be added to the myexp.exp file for this to be true? (If necessary, modify myrun.run with each answer choice to test for the correct answer.)

a) run myrun algorithm RR 25 key “RR 25”
b)
run myrun algorithm RR 15 key “RR 15”
c)
run myrun algorithm RR 8 key “RR 8”
d) None of the above lines will cause RR scheduling to behave the same as FCFS.


———————————————————————————————–

Assessment

1%

~ This is the End of Lab 4 ~

Tags: , , , , , , , , , ,