0% found this document useful (0 votes)
379 views8 pages

Problem Bank 28

The document describes an assignment with 3 parts that aims to provide understanding of pipelining architecture, scheduling algorithms, and multithreading using a CPU-OS simulator; part I deals with pipeline architecture, part II with scheduling (FCFS, RR, SJF), and part III with multithreading; students must submit a file with their group number by March 3rd through Canvas and avoid plagiarism.

Uploaded by

Rosaria Sammuels
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
379 views8 pages

Problem Bank 28

The document describes an assignment with 3 parts that aims to provide understanding of pipelining architecture, scheduling algorithms, and multithreading using a CPU-OS simulator; part I deals with pipeline architecture, part II with scheduling (FCFS, RR, SJF), and part III with multithreading; students must submit a file with their group number by March 3rd through Canvas and avoid plagiarism.

Uploaded by

Rosaria Sammuels
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Assignment II

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:

 The assignment carries 12 marks


 Grading will depend on
o Contribution of each student in the implementation of the assignment
o Plagiarism or copying will result in -12 marks
************************FILL IN THE DETAILS GIVEN BELOW**************
Assignment Set Number: Problem Bank 28

Group Name: Group Number 188

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%)

Sl. Name (as appears in Canvas) ID NO Contribution (%)


No.

1 Ananya Karmakar 2020fc04629 33.33%

2 Akshay Bindlish 2020fc04616 33.33%

3 Surabhi Inamdar 2020fc04633 33.33%

Resource for Part I, II and III:


 Use following link to login to “eLearn” portal.
o https://elearn.bits-pilani.ac.in
 Click on “My Virtual Lab – CSIS”
 Using your canvas credentials login in to Virtual lab
 In “BITS Pilani” Virtual lab click on “Resources”. Click on “Computer Organization
and software systems” course. Refer to Lab Capsule 4, Lab Capsule 5, Lab Capsule 6.
Part I: Pipeline Processor
Consider the following program:
program pipeline8
p=1
q=2
r=3
q=q+p
r=r+p
p=p/3
p=r
end
Compile the code and load it in CPU-OS simulator. Perform the following:

Execute the above program using non-pipelined processor and pipelined


processor and answer the following questions.

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.

a) How many stages are there in non-pipelined processor? List them


Fetch
Decode
Read Operands
Execute
Write Result

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:

Pipelined processor Clocks Instruction CPI Speed up Data Contents of


conditions Count Factor hazard registers used by
(Yes/No) the program

Check “Do not 40 21 1.9 2.63 No R00 0


insert bubbles” R01 2
check box R02 3
R03 2
R04 0
R05 2
R06-R31 0

Uncheck “Do not 45 21 2.14 2.34 Yes R00 0


insert bubbles” R01 4
R02 3
R03 4
R04 0
R05 4
R06-R31 0

b) Is there a way to improve the CPI and Speed up factor?


Solution:
To improve CPI and the speed-up factor you need to enable the pipeline. The
programmer can help improve CPI but it is best to leave that to an optimising
compiler and clever CPU architecture. The simulator's built-in compiler offers some
help in reducing the CPI, for example loop unrolling, constant folding, identifying
code dependencies, etc. In pipelined architecture, the goal is to reduce/prevent
hazards and the above optimisations help do that. In addition, the pipeline has a
means of forwarding operands, i.e. prior to previous instructions updating registers in
a later stage, that contributes to reducing the CPI.

Part II: Process Scheduling


Consider the following 3 source codes:
Source Code 1:
program My_Pgm1
i=1
for n = 1 to 5
x=i+n
next
end
Source Code 2:
program My_Pgm2
i = 10
for n = 1 to 8
x=i+n
next
end

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

Consider the following source code

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.

Answer the following questions:

a) What is the value of “Total”?


11
b) How many processes and how many threads are created?
1 process and 2 threads
c) Identify the name of the processes and threads.
1 process: P1
2 threads: P1 and P1T0
d) What is the PID and PPID of the processes and threads created?

Pid PPid

P1 1 0

P1T0 2 1

e) Represent the parent and child relationship using tree representation.

You might also like