0% found this document useful (0 votes)
8 views1 page

OS Lab Assignment 5

The document outlines an assignment for a B.Tech Operating System Lab, consisting of three programming tasks. The first task involves creating a multithreaded program to calculate the average, minimum, and maximum of a list of numbers. The second task requires matrix operations using threads for summation and difference, while the third task involves calculating prefix products using multiple threads for an arbitrary number of integers.

Uploaded by

roshnarajesh18
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)
8 views1 page

OS Lab Assignment 5

The document outlines an assignment for a B.Tech Operating System Lab, consisting of three programming tasks. The first task involves creating a multithreaded program to calculate the average, minimum, and maximum of a list of numbers. The second task requires matrix operations using threads for summation and difference, while the third task involves calculating prefix products using multiple threads for an arbitrary number of integers.

Uploaded by

roshnarajesh18
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/ 1

Computer Science and Engineering Department

Motillal Nehru National Institute of Technology Allahabad


B.Tech IV Semester
Operating System Lab (CSN14401)
Assignment 5

1. 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 is 82
The minimum value is 72
The maximum value is 95

2. Write a program to create two matrices, A and B, of sizes 40x40, which only take binary inputs 0
and 1. Create two threads running parallel where one thread will compute the summation of the two
matrices and the other will compute their difference. There will be one main thread which will wait
for the two parallel threads to complete their task and it will compute the multiplication of the two
previously obtained output and print the final output.

3. Write a program that receives an arbitrary number of integers as arguments. Let N be the number of
arguments provided by the user. The program creates N threads, each of which is assigned an ID i,
with 0 < i <= N. The ith thread computes a prefix product of all numbers up to and including the ith
argument, i.e. the first thread returns the first number, the second thread computes the product of the
first and second number, and so on. The main thread then waits for all threads to complete and
prints their result in order in the format "product <i> = <product>".
Example output:
Sample Input: 4 3 9 5 21
product 1 = 4
product 2 = 12
product 3 = 108
product 4 = 540
product 5 = 11340

You might also like