Objective This assignment will introduce you to the thread creation in UNIX using the POSIX threads API. Specifications You have to write a multithreaded program to add, subtract, and multiply two matrices. Each thread will calculate an element of the result matrix based on the operation prompted by the user. Input Format: Your program should read the information about the input matrices from a file with the following format: This input will look like: 3 3 // Size of matrix 1 (rows, columns) 1.0 2.0 3.0 // First Matrix values (columns 4.0 5.0 6.0 // separated by space, rows 7.0 8.0 9.0 // separated by end-of-line 3 3 // Size of matrix 2 (rows, columns) 1.0 2.0 3.0 // Second Matrix values (columns 4.0 5.0 6.0 // separated by space, rows 7.0 8.0 9.0 // separated by end-of-line Note: the size of the matrices (row and column) will be integer values separated by space, and the data type of the matrices elements will be double. Implementation 1. The main thread: this thread will start by reading the information about the matrices from the input file. Then, it will start a loop prompting the user for the type of operation to be executed (1= add matrices, 2=subtract matrices, 3= multiply matrices, 4= exit program, other value= print “non-valid option”. After selecting a valid operation, it will verify if this operation can be executed based on the size of the matrices. For matrices with valid dimensions to execute the selected operation, this thread will create “m” child threads to calculate the values of Document Preview:

COSC 3360 – 6310 – Operating System Fundamentals Assignment #1 for Summer 2018: The Multithreaded Matrix Operator. Due on Tuesday, June 13 at 11:59:59 PM Objective the result matrix (where m is the number of elements of the result matrix). It will wait for This assignment will introduce you to the thread all the child threads to finish its execution, creation in UNIX using the POSIX threads API. printing the information about the termination of each child thread. Finally, the program will Specifications print the average execution time of the child threads and the result of the matrix operation. You have to write a multithreaded program to add, subtract, and multiply two matrices. Each 2. Child threads: these are the threads that will thread will calculate an element of the result calculate each element of the result matrix. matrix based on the operation prompted by the Each child thread will read the information user. required to calculate the assigned element of the result matrix. It will perform the operations Input Format: Your program should read the needed to calculate this element. Finally, it information about the input matrices from a file will save the information about the result with the following format: value and its execution time into memory. This input will look like: PThreads 3 3 // Size of matrix 1 (rows, columns) 1. Don’t forget the pthread include: 1.0 2.0 3.0 // First Matrix values (columns #include 4.0 5.0 6.0 // separated by space, rows 2. All variables that will be shared by all threads 7.0 8.0 9.0 // separated by end-of-line must be declared static. 3 3 // Size of matrix 2 (rows, columns) 3. To start a thread, use the function: 1.0 2.0 3.0 // Second Matrix values (columns pthread_create(&tid, NULL, funct,(void *) 4.0 5.0 6.0 // separated by space, rows arg), where funct is the identifier of the 7.0 8.0 9.0 // separated by end-of-line function with the code of the thread and…

Attachments:

COSC-3360-Ass….pdf