0% found this document useful (0 votes)
60 views29 pages

Os Lab Assessment-2

The document outlines 4 programming assignments related to OS concepts: creating threads to calculate factorial and statistics, using shared memory for inter-process communication between a client and server, implementing process scheduling algorithms like FCFS, SJF, priority and round robin, and simulating the Banker's Algorithm for deadlock avoidance including checking for safe states and handling additional resource requests. The assignments range from easy to high difficulty and require writing code in C/C++ to demonstrate concepts like threads, shared memory, process scheduling, and deadlock avoidance.

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)
60 views29 pages

Os Lab Assessment-2

The document outlines 4 programming assignments related to OS concepts: creating threads to calculate factorial and statistics, using shared memory for inter-process communication between a client and server, implementing process scheduling algorithms like FCFS, SJF, priority and round robin, and simulating the Banker's Algorithm for deadlock avoidance including checking for safe states and handling additional resource requests. The assignments range from easy to high difficulty and require writing code in C/C++ to demonstrate concepts like threads, shared memory, process scheduling, and deadlock avoidance.

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/ 29

OS LAB ASSESSMENT-2

NAME: SHASHANK AMANANA


REGNO:20BCE2028

SLOT: L27-28

A)Process and Thread Management


Write a program to create a thread and perform the following (Easy)
Create a thread runner function • Set the thread attributes • Join the parent and thread
•Wait for the thread to complete
CODE:
OUTPUT:
B) Write a program to create a thread to find the factorial of a natural number ‘n’

OUTPUT:
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)

SERVER CODE:
CLIENT CODE:

OUTPUT:
D) Write a multithreaded program that calculates various statistical values for a list of
numbers. This program will be passed a series of numbers on the command line and will then
create three separate worker threads. One thread will determine the average of the
numbers, the second will determine the maximum value, and the third will determine the
minimum value. For example, suppose your program is passed the integers 90 81 78 95 79 72
85 , the program will report the average value as 82. The minimum value as 72. The maximum
value as 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
OUTPUT:
CPU SCHEDULING

(a) Implement the various process scheduling algorithms such as FCFS, SJF, Priority (Non
Preemptive)
(b) Implement the various process scheduling algorithms such as Priority, Round Robin
(preemptive).
CODE:
OUTPUT:
DATA:
FCFS:
SJF (PRE EMPTIVE)

SJF( NON PRE-EMPTIVE)


PRIORITY( PRE EMPTIVE)

PRIORITY( NON PRE EMPTIVE)


ROUND ROBIN
C) Consider a corporate hospital where we have n number of patients waiting for
consultation. The amount of time required to serve a patient may vary, say 10 to 30 minutes.
If a patient arrives with an emergency,he /she should be attended immediately before other
patients, which may increase the waiting time of other patients. If you are given this problem
with the following algorithms how would you devise an effective scheduling so that it
optimizes the overall performance such as minimizing the waiting time of all patients. [Single
queue or multi-level queue can be used]. Consider the availability of single and multiple
doctors • Assign top priority for patients with emergency case, women, children, elders, and
youngsters. • Patients coming for review may take less time than others. This can be taken
into account while using SJF.
1. FCFS
2. SJF (primitive and non-pre-emptive)

CODE:
FCFS
OUTPUT:
FCFS

CODE:

SJF
OUTPUT:
d. Simulate with a program to provide deadlock avoidance of Banker’s Algorithm including
Safe state and additional resource request
CODE:
OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy