Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Begin by getting the provided, single-threaded, program to build and ex- ecute. If you are not using an onyx node, you might need to

1. Begin by getting the provided, single-threaded, program to build and ex- ecute. If you are not using an onyx node, you might need to install some software (e.g., the FLTK graphics development library). Although you still need to link against the FLTK library, you can get textual output (to stdout), rather than graphical output (to an X11 win- dow), via an environment variable. For example: $ DISPLAY= ./wam 2. Modify the program to use your queueimage text in transcribed. You should only need to change main.c. Functions produce and consume should only communicate through a queue. 3. Modify the program to use a separate thread for each produce and consume call. Design and implement a new module for the thread code. Pro- vide a function to call another function (e.g., produce or consume) n times, in n new threads (q.v., pthread create). Pass an argument to each thread/function, providing the data it needs to access. The argu- ment can be a pointer to a structure containing multiple values. Provide another function to wait for the n threads, called earlier, to nish (q.v., pthread join).

4. Design and implement an MT-safe \wrapper" module, around your queue module. For this assignment, one lock per queue is good enough. Your queue module need not change. To increase the entertainment value of your simulation, allow an argument to mtq new to set a maximum capacity, with zero meaning unbounded. I used a capacity of four. This will cause produce congestion.

5. Modify the program to use your MT-safe wrapper, rather than your queue module. You should only need to change main.c, referring to types and functions from the MT-safe wrapper, rather than the MT-unsafe original.

CS 452 (S23) HW2 (Jan 31 Tue) 3/5 How to Proceed 1. Begin by getting the provided, single-threaded, program to build and exocute. If you are not using an onyx node, you might nood to install some soll.ware (e.g., the FITK graphics development library). Although you still neal to link aggansit the FITK library, you can get. textual output (to stdout), rather than graphical output (to an X11 window), via an environment variable. For cxample: $ DISPLAY =// wam 2. Modify the program to use your queue, from the earlier homework azeignment. You should only nood to change main.c. Functions produce and consume should only commurical.e lhrough a queue. 3. Modify the program to use s separate thread for each produce and consume call. Design and implement a new module for the thread oode. Provide a function to call another function (ag., produce or consune) n times, in n new threads (q. v, pthread_create). Pass an argument to each thread/function, providing the data it needs to access. The argument can be a pointer to a gtructure containing multiple values. Provide another function to wait for tho n threads, called carlicr, to finish (q.v., pthread_join). MT programming is described in Chapters 29 and 30 of our textbook. My produce function, in ma.in, c, looks like this: At rhis point, your program should orash: Your MT' code is acossing your MT-unsato qucuc. 4. Deeign and implement an MT-sate "wrapper" module, around your queue module. For this assignment, one lock per queue is good cnough. Your queue module need not change. This is also deseribed in Chipleers 29 and 30 of our text.book. To increase the entertainment value of your simulation, allow an argument to mitq nex to sct a maximum capacity, with zero moaning unbounded. I used a capacily of feur. This will exase produce congestion

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions