OS - Wipro - Lab Sheet-02

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Department of Computer Science and Information Technology

Operating System: SSWTZC364/ CSIWZC364/ SEWIZC364


Lab Work Sheet-02
1. Objective:
At the end of this lab session, students will be able to
 Write a source code that creates threads
 Use the simulator to compile and run the code
 Display the list of processes/threads and the tree of processes showing the
parent/child process relationship
 Demonstrate that threads share their parent’s data areas

2. Prerequisite:
Refer to the “Multithreading” video capsule available in eLearn Portal’s
Labware page.

3. Important Instructions:
a. Experiments should be conducted on the BITS Nuvepro Cloud Lab only.
Experiments conducted outside this lab platform will not be evaluated.
b. Instructions on how to access and use the Nuvepro Cloud lab platform are
available in the document “Steps to access cloud-based CS/IS virtual lab.pdf”.
c. While using the Nuvepro Cloud, save all your work in the Persistent folder,
which is available on the desktop. (Important Note: Always take backup of this
folder.)
d. The completed worksheet should be uploaded in Taxila (elearn) portal only.
The last date for uploading the document is 24-sept-2024.
e. This worksheet/lab activity carries 2.5% of weightage.
f. Refrain from copying or sharing documents with others. Any evidence of such
practice will attract severe penalties.
g. Any queries related to LAB Activities should be asked only through eLearn
portal under discussion forum. Use the below mentioned link to access the
same:
Section Discussion Forum Link
SEWIZC364 https://taxila-aws.bits-
pilani.ac.in/mod/forum/discuss.php?d=68446#p145218
SSWTZC364 https://taxila-aws.bits-
pilani.ac.in/mod/forum/discuss.php?d=68447#p145219

1
CSIWZC364 https://taxila-aws.bits-
pilani.ac.in/mod/forum/discuss.php?d=68448#p145220

4. Lab Exercise:
Problem Statement 1: Consider the following source code. (Program name (should be
your <PB1_ID Number>. Any other name will fetch “0 marks”)

program <PB1_ID Number>


total = 0
sub thread1 as thread
for i = 1 to 2
total = total + i
next
end sub
sub thread2 as thread
for i = 3 to 4
call thread1
total = total + i
next
end sub
call thread2
wait
writeln (“Total =”, total)
end

Answer the following questions:

a) Compile the above source code and load it in the main memory. Provide the snapshot of
the compiled code and code loaded in the main memory.
Note: To avoid white spaces and double quotes in the program, copy the given program
in the note pad and then transfer it in compiler editor.

2
b) Create a single process, choose RR scheduling algorithm with time quantum of 5 seconds
with no-priority. Run the Process. Provide the evidence in the form of snapshot of such a
setting.
c) What is the value of “Total” ? Share the snapshot.
d) How many processes and threads are created?
e) Identify the name of the processes and threads.
f) What is the PID and PPID of the processes and threads created?
g) Represent the parent and child relationship using tree representation

Problem Statement 2: Following exercise demonstrates how the threads share the parents
data area. Consider the following program (Program name should be your <PB2_ID
Number>. Any other name will fetch “0 marks”).

Set TEXT1 as your ID Number and TEXT2 as your first name.

program <PB2_ID Number>

var s1 string(12)
var s2 string(20)
sub thread1 as thread
s1 = “TEXT1”
writeln(“In thread1”)
for i = 1 to 5
writeln("In thread1: ", i)
next
end sub

sub thread2 as thread


call thread1
s2 = “TEXT2”
writeln(“In thread2”)
for i = 1 to 5
writeln("In thread1: ", i)
next

end sub

call thread2
writeln(“In main”)
wait

3
writeln(s1)
writeln(s2)
end

Answer the following questions:

a) Compile the above source code and load it in the main memory. Provide the snapshot of
the compiled code and code loaded in the main memory.
Note: To avoid white spaces and double quotes in the program, copy the given program
in the note pad and then transfer it in compiler editor.
b) Create a single process, choose RR scheduling algorithm with time quantum of 5 seconds
with no-priority. Run the Process. Provide the evidence in the form of snapshot of such a
setting.
c) How many processes and threads are created?
d) Identify the name of the processes and threads.
e) What is the PID and PPID of the processes and threads created?
f) Represent the parent and child relationship using tree representation.
g) Justify that threads share their parent’s data area.

You might also like