0% found this document useful (0 votes)
9 views3 pages

OS LAB TEST 1 Thursday 10-12 LabTest 1

Uploaded by

23103400
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)
9 views3 pages

OS LAB TEST 1 Thursday 10-12 LabTest 1

Uploaded by

23103400
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/ 3

Operating System and Systems Programming Lab (15B11CI472)

Lab Test- 1 (Thursday 10:00 AM), 18/09/2025)

Time: 50 Minutes Max Marks:20 ODD Machine

Q1. Write a multithreaded C program using pthreads to work on an array of integers. Thread 1
should find the maximum and minimum element. Thread 2 should calculate the sum and average
of all elements. The main thread should:
● Take array input
● Create the two threads.
● Wait for both threads to complete.
● Display the results after joining both threads.
[CO2, 10 Marks]

Sample Input:

Enter size: 5
Enter array: 10 5 8 20 3

Output:

Maximum: 20
Minimum: 3
Sum: 46
Average: 9.20

Q2. A real-time system executes processes with Priority scheduling (Preemptive). Each
process has Process ID, Arrival Time, Burst Time and Priority (smaller number = higher
priority).Write a C program to implement Preemptive Priority Scheduling. Compute for each
process: Completion Time (CT), Turnaround Time (TAT), Waiting Time (WT), Average TAT and
Average WT. [CO3, 10 Marks]
Sample Input:

Number of processes: 3
Process Arrival Time Burst Time Priority
P1 0 5 2
P2 1 3 1
P3 2 8 3
Sample Output:
Process AT BT Priority CT TAT WT

P1 0 5 2 8 8 3

P2 1 3 1 4 3 0

P3 2 8 3 16 14 6

Average TAT = (8 + 3 + 14) / 3 = 25 / 3 = 8.33


Average WT = (3 + 0 + 6) / 3 = 9 / 3 = 3.0

EVEN Machine

Q1. Write a multithreaded C program using the pthread library to perform the following
operations on an integer array of size N. Thread 1 should count how many even and odd numbers
are present in the array. Thread 2 should search for a given element X in the array using linear
search/binary search. The main thread must:

● Read the array elements and the search element X.


● Create the two threads.
● Wait for both threads to complete.
● Display the results (even/odd count and search result).
[CO2, 10 Marks]

Sample Input:

Enter size of array: 7


Enter array: 10 23 45 66 78 90 11
Enter element to search: 66
Expected Output:

Even numbers: 4
Odd numbers: 3
Element 66 found at position: 4
Q2. A real-time system executes processes with Shortest Remaining Time First (SRTF –
Preemptive SJF) scheduling. Each process has Process ID, Arrival Time and Burst Time. Write
a C program to implement Shortest Remaining Time First (SRTF – Preemptive SJF)
scheduling. Compute for each process: Completion Time (CT), Turnaround Time (TAT), Waiting
Time (WT), and average TAT, WT. [CO3, 10 Marks]

Sample Input:
Enter number of processes: 4

Process Arrival Time Burst Time


P1 0 7
P2 2 4
P3 4 1
P4 5 4

Sample Output:
Process AT BT CT TAT WT

P1 0 7 16 16 9

P2 2 4 7 5 1

P3 4 1 5 1 0

P4 5 4 11 6 2

Average TAT = (16 + 5 + 1 + 6) / 4 = 7.0


Average WT = (9 + 1 + 0 + 2) / 4 = 3.0

You might also like