0% found this document useful (0 votes)
40 views

Os Lab Assessment-3: Name: Shashank Amanana REGNO:20BCE2028 SLOT: L27-28 A)

Shashank Amanana implemented several concurrency problems for their OS lab assessment. They coded solutions for the reader-writer problem, dining philosophers problem, producer-consumer problem, barber shop simulation, and a producer-consumer problem using POSIX semaphores. For each problem, they included the code and output.

Uploaded by

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

Os Lab Assessment-3: Name: Shashank Amanana REGNO:20BCE2028 SLOT: L27-28 A)

Shashank Amanana implemented several concurrency problems for their OS lab assessment. They coded solutions for the reader-writer problem, dining philosophers problem, producer-consumer problem, barber shop simulation, and a producer-consumer problem using POSIX semaphores. For each problem, they included the code and output.

Uploaded by

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

OS LAB ASSESSMENT-3

NAME: SHASHANK AMANANA


REGNO:20BCE2028
SLOT: L27-28

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


Code:
Output:
b. Implement the solution for dining philosopher’problem.
CODE
Output:
(c) Implement the solution for producer consumer problem (Easy)

Code:

Output:
(d) The analogy is based upon a hypothetical barber shop with one barber. There is a barber shop
which has one barber, one barber chair, and n chairs for waiting for customers if there are any to sit
on the chair.
 If there is no customer, then the barber sleeps in his own chair. When a customer arrives,
he has to wake up the barber.

 If there are many customers and the barber is cutting a customer’s hair, then the remaining
customers either wait if there are empty
chairs in the waiting room or they leave if no chairs are empty.

Code:
Output:
e) A pair of processes involved in exchanging a sequence of integers. The number of integers that
can be produced and consumed at a time is limited to 100. Write a Program to implement the
producer and consumer problem using POSIX semaphore for the above scenario.
(Medium)

Code:
Output:
(f) Deadlock Avoidance Using Semaphores:
Implement the deadlock free solution to Dining Philosophers problem to illustrate the problem of
deadlock and/or starvation that can occur when many synchronized threads are competing for
limited resources.(hard)

Code:

Output:

You might also like