Problem Bank 28
Problem Bank 28
Problem Bank 28
Assignment Description:
The assignment aims to provide deeper understanding of Pipelining Architecture,
Scheduling and Multithreading using CPU- OS Simulator. The assignment has three
parts.
Part I deals with Pipeline Architecture
Part II deals with scheduling algorithm(FCFS, RR, SJF)
Part III deals with Multithreading
Submission:
You will have to submit this documentation file and the name of the file should be
GROUP-NUMBER.pdf. For Example, if your group number is 1, then the file name should
be GROUP-1.pdf.
Submit the assignment by 3rd March 2021, through canvas only. File submitted by any
means outside CANVAS will not be accepted and marked.
In case of any issues, please drop an email to the course TA, Ms. Michelle Gonsalves
([email protected]).
Caution!!!
1. Assignments are designed for individual groups which may look similar and you may
not notice minor changes in the assignments. Hence, refrain from copying or sharing
documents with others. Any evidence of such practice will attract severe penalty.
2. Marks will not be awarded for individual submissions
Evaluation:
Contribution Table:
Contribution (This table should contain the list of all the students in the group. Clearly
mention each student’s contribution towards the assignment. Mention “No Contribution” in
cases applicable. If the contribution is equal the write 100%)
Note: Every time flush the pipeline before running the code
A) Non-pipelined Processor:
To enable non-pipelined processor, check “No instruction pipeline” check box in control
panel.
b) Fill in the following after executing of above program using non-pipelined processor.
Clocks Instruction CPI Speed up Factor
Count
Non Pipelined 122 21 5.81 .86
processor
c) What are the contents of General purpose registers after the execution of the program?
R00 0
R01 4
R02 3
R03 4
R04 0
R05 4
R06-R31 0
B) Pipelined processor:
To use, enable pipelined processor, uncheck “No instruction pipeline” check box in
control panel.
a) Fill in the following table with respect to pipelined processor execution of the above
program:
Source Code 3:
program My_Pgm3
i = 10
for n = 1 to 10
x=i+n
next
end
Source Code 4:
program My_Pgm4
i = 10
for n = 1 to 5
x=i+n
next
end
Create 4 processes P1, P2. P3 and P4 from source codes 1, 2, 3and 4 respectively with
following properties. Fill up the following table by considering Log data only
Scheduling Algorithm: FCFS
Process Arrival Time Waiting time (sec)
P1 0 0.1
P2 2 4.1
P3 6 13.39
P4 4 9.62
Average waiting time : 6.8 sec
Scheduling Algorithm: Round Robin with time quantum 2
Process Arrival Time Waiting time (sec)
P1 0 1.82
P2 2 1.6
P3 6 1.6
P4 4 1.86
Average waiting time : 26.44 sec
Scheduling Algorithm: Shortest Job First (Pre-emptive)
Process Arrival Time Priority Waiting time (sec)
P1 0 1 0.05
P2 2 2 4.18
P3 6 1 13.48
P4 4 2 9.76
Average waiting time: 6.87 sec
Scheduling Algorithm: Shortest Job First (Non-Pre-emptive)
Process Arrival Time Priority Waiting time (sec)
P1 0 1 0.06
P2 2 2 4.2
P3 6 3 13.69
P4 4 4 9.86
Average waiting time: 6.95 sec
Out of Four cases, which one is better and why?
In this case FCFS is better as the average waiting time in case of FCFS is less than other
scheduling algorithm for the given code. Though SJF, both pre-emptive and non-pre-
emptive, are very close to FCFS in terms of the average waiting time and waiting time for
each process this is due to the short burst time of all the processes.
Part III: Multi-Threading
program ThreadTest
total = 40
sub thread1 as thread
for i = 1 to 2
total = total + i + 4
next
end sub
sub thread2 as thread
for i = 3 to 4
total = total + i
call thread1
next
end sub
call thread1
wait
writeln (“Total =”, total)
end
Compile the above source code and load it in the main memory. Create a single
process, choose RR scheduling algorithm with time quantum of 3 ticks. Run the
Process.
Pid PPid
P1 1 0
P1T0 2 1