VL2018191004391 Ast03 PDF

You might also like

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

ITE 2002-SWE3001-Operating System Lab

Assessment-1 Questions

1) Shell Programming
 Handling the command line arguments
 String reversal
 If-Else, Nested If Else,Switch cases in shell

2) Parent child process creation using fork( ) and exec() system


call

m
e r as
Checking the Process Identifier

co
Assigning new task to child

eH w
Providing the path name and program name to exec()

o.
rs e
Synchronizing Parent and child process using wait()
ou urc
Assessment-2 Questions
o

Process and Thread Management


aC s
v i y re

(a) Write a program to create a thread and perform the


following (Easy)
 Create a thread runner function
ed d

 Set the thread attributes


ar stu

 Join the parent and thread


 Wait for the thread to complete
sh is

(b) Write a program to create a thread to find the factorial of a


Th

natural number ‘n’. (Medium)


(c) Assume that two processes named client and server running
in the system. It is required that these two processes should
communicate with each other using shared memory
concept. The server writes alphabets from a..z to the shared
memory .the client should read the alphabets from the
shared memory and convert it to A…Z. Write a program to
demonstrate the above mentioned scenario. (Medium)

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
Assessment-3 Questions
Process and Thread Management
d) The Collatz conjecture concerns what happens when we take any
positive integer n and apply the following algorithm:
n = n/2, if n is even n = 3 × n + 1, if n is odd
The conjecture states that when this algorithm is continually applied,
all positive integers will eventually reach 1. For example, if n = 35,
the sequence is 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1.Write
a C program using the fork () system call that generates this

m
e r as
sequence in the child process. The starting number will be provided

co
eH w
from the command line. For example, if 8 is passed as a parameter

o.
on the Command line, the child process will output 8, 4, 2, 1.
rs e
Because the parent and child processes have their own copies of the
ou urc
data, it will be necessary for the child to output the sequence. Have
the parent invoke the wait () call to wait for the child process to
o
aC s

complete before exiting the program (High).


v i y re

e) Write a multithreaded program that calculates various statistical


values for a list of numbers. This program will be passed a series of
ed d

numbers on the command line and will then create three separate
ar stu

worker threads. One thread will determine the average of the


numbers, the second will determine the maximum value, and the
sh is

third will determine the minimum value. For example, suppose your
Th

program is passed the integers 90 81 78 95 79 72 85


The program will report The average value is 82 The minimum value
is 72 The maximum value is 95 The variables representing the
average, minimum, and maximum values will be stored globally. The
worker threads will set these values, and the parent thread will
output the values once the workers have exited. (High)
.

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
Assessment-4 Questions
CPU Scheduling
(a) Implement the various process scheduling algorithms such as
FCFS, SJF, Priority (Non Preemptive). (Easy )
(b) Implement the various process scheduling algorithms such as
Priority, Round Robin (preemptive). (Medium)

Assessment- 5 Questions

m
e r as
CPU Scheduling

co
eH w
(c) Consider a corporate hospital where we have n number of

o.
patients waiting for consultation. The amount of time required
rs e
ou urc
to serve a patient may vary, say 10 to 30 minutes. If a patient
arrives with an emergency,he /she should be attended
o

immediately before other patients, which may increase the


aC s

waiting time of other patients. If you are given this problem with
v i y re

the following algorithms how would you devise an effective


scheduling so that it optimizes the overall performance such as
ed d

minimizing the waiting time of all patients. [Single queue or


ar stu

multi-level queue can be used].


• Consider the availability of single and multiple doctors • Assign
sh is

top priority for patients with emergency case, women, children,


Th

elders, and youngsters. • Patients coming for review may take


less time than others. This can be taken into account while using
SJF.
a. FCFS
b. SJF (primitive and non-pre-emptive ) (High )
(d) Many CPU-scheduling algorithms are parameterized. For example,
the RR algorithm requires a parameter to indicate the time slice.
Multilevel feedback queues require parameters to define the number

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
of queues, the scheduling algorithm for each queue, the criteria used
to move processes between queues, and so on. These algorithms are
thus really sets of algorithms (for example, the set of RR algorithms
for all time slices, and so on). One set of algorithms may include
another (for example, the FCFS algorithm is the RR algorithm with an
infinite time quantum). What (if any) relation holds between the
following pairs of algorithm sets? Implement the below mentioned
algorithms and determine the efficiency of each algorithm. (Assume
your own data for input)
1. Priority and SJF 2. Multilevel feedback queues and FCFS 3. Priority

m
e r as
and FCFS 4. RR and SJF

co
eH w
o.
rs e Assessment- 6 Questions
ou urc
Process Synchronization
o

(a) Implement the solution for reader – writer’s problem. Easy


aC s
v i y re

(b) Implement the solution for dining philosopher’s problem. Easy


(c) A pair of processes involved in exchanging a sequence of integers.
ed d

The number of integers that can be produced and consumed at a


ar stu

time is limited to 100. Write a Program to implement the producer


and consumer problem using POSIX semaphore for the above
sh is

scenario. Medium
Th

Assessment- 7 Questions
Process Synchronization
(d) Write a Program to implement banker’s algorithm for Deadlock
avoidance. Medium
(e) The Crisp Cafe in the strip mall near my house serves customers
FIFO in the following way. Each customer entering the shop takes a

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
single “ticket” with a number from a “sequencer” on the counter. The
ticket numbers dispensed by the sequencer are guaranteed to be
unique and sequentially increasing. When a barista (a person who
makes and serves coffee) is ready to serve the next customer, it calls
out the “event count”, the lowest unserved number previously
dispensed by the sequencer. Each customer waits until the
eventcount reaches the number on its ticket. Each barrista waits until
the customer with the ticket it called places an order. Implement
sequencers, tickets, and eventcounts using mutexes and condition
variables. Your solution should also include code for the barrista and

m
customer threads. High

e r as
co
eH w
(f) The Sleeping Professor Problem: Once class is over, professors

o.
like to sleep — except when students bother them to answer
rs e
questions. You are to write procedures to synchronize threads
ou urc
representing one professor and an arbitrary number of students. A
professor with nothing to do calls IdleProf(), which checks to see if a
o

student is waiting outside the office to ask a question. IdleProf sleeps


aC s
v i y re

if there are no students waiting, otherwise it signals one student to


enter the office, and returns. A student with a question to ask calls
ArrivingStudent(), which joins the queue of students waiting outside
ed d
ar stu

the office for a signal from the professor; if no students are waiting,
then the student wakes up the sleeping professor. The idea is that the
professor and exactly one student will return from their respective
sh is

functions “at the same time”: after returning they discuss a topic of
Th

mutual interest, then the student goes back to studying and the
professor calls IdleProf again. Implement IdleProf and ArrivingStudent
using mutexes. High

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
Assessment- 8 Questions
Memory Management
(a) Consider a memory hole of size 1kb initially. When a sequence of
memory request arrives as following, illustrate the memory allocation
by various approaches and calculate the total amount memory wasted
by external fragmentation and internal fragmentation in each
approach.
a. First fit; b. Best fit c. Worst fit (Easy)
(b) Write a program to implement the page replacement algorithms.

m
e r as
co
a. FIFO b. LRU c. OPT (Medium)

eH w
(c) Write a program that implements the FIFO, LRU, and optimal

o.
rs e
pager replacement algorithms. First, generate a random page-
ou urc
reference string where page numbers range from 0 to 9. Apply the
random page reference string to each algorithm, and record the
o

number of page faults incurred by each algorithm.Implement the


aC s
v i y re

replacement algorithms so that the number of page frames can vary


from 1 to 7. Assume that demand paging is used. (High)
ed d
ar stu

Assessment- 9 Questions
File system and Disk Management
sh is
Th

(a) Implement the following Disk scheduling algorithms:


a. SSTF b. SCAN c. C-SCAN d. FCFS
Medium

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/
(b) Consider a file of size 1 MB. The size of a disk block is 512Bytes.
Assume any number of available free blocks in the disk contiguously
or noncontiguously. Implement the following algorithms to perform
file allocation. Determine the efficiency of each file allocation
strategies. a. Sequential b. Indexed c. Linked (High)

m
e r as
co
eH w
o.
rs e
ou urc
o
aC s
v i y re
ed d
ar stu
sh is
Th

https://www.coursehero.com/file/34664196/VL2018191004391-AST03pdf/

Powered by TCPDF (www.tcpdf.org)

You might also like