Programming in C: Please read the discription on the attached picture.

Consider a system with N blocks of storage, each of which holds one unit of information (e.g. an integer, character, or employee record). Initially, these blocks are empty and are linked onto a list called freelist. Three threads communicate using shared memory/global variables in the following manner:
Shared Variables: freelist, list-1, list-2: block (where block is some data type to hold items)
Thread-1:var b: pointer to type block;while (1){ b:= unlink(freelist); produce_information_in_block(b); link(b, list-1);}
Thread-2:var x,y: pointer to type block;while (1){ x:=unlink(list-1); y:=unlink(freelist); use_block_x_to_produce info_in_y(x, y); link(x, freelist); link(y, list-2);}
Thread-3:var c: pointer to type block;while(1){ c:=unlink(list-2); consume_information_in_block(c); link(c, freelist);}
You must insert semaphores into these three threads to enforce the necessary mutual exclusion and to synchronize the threads. Your solution must be deadlock-free and concurrency should not be unnecessarily restricted.
Items to submit:
You must submit your group’s pseudocode showing how semaphores were used to solve mutual exclusion and synchronization problems. For each P() and V() operation you insert, you must provide a comment describing why you have inserted this particular operation on this particular semaphore at this particular position in the code.
You must submit a report that includes a list of all semaphores used in your solution. For each semaphore, you must
State whether it is a binary or counting semaphore.
State whether that semaphore is used for synchronization or for mutual exclusion.
Describe the role of that semaphore in this solution. For example, what problems are solved by using this semaphore.

Extra Credit Opportunity: Using the POSIX library, rewrite the code for the threads using semaphores to implement the necessary mutual exclusion and synchronization. If your solution is correct, and your code works, you can receive up to a maximum of 1.5 points added to your course grade.

Don't use plagiarized sources. Get Your Custom Essay on
Programming in C: Please read the discription on the attached picture.
Get an essay WRITTEN FOR YOU, Plagiarism free, and by an EXPERT!
Order Essay
superadmin

Recent Posts

What is the easy difination of science | Quick Solution

Science is the pursuit and application of knowledge and understanding of the natural and social…

3 years ago

definition, values, meaning of such values and type of goods with such elasticity value …….. | Quick Solution

Clearly stating the definition, the values, the meaning of such values and the type of…

3 years ago

Acct 422 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

3 years ago

Acct 322 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

3 years ago

Macro Economics Question | Quick Solution

https://www.npr.org/sections/ed/2018/04/25/605092520/high-paying-trade-jobs-sit-empty-while-high-school-grads-line-up-for-university Click on the link above. Read the entire link and answer the questions below…

3 years ago

MGT 322 – Nora D | Quick Solution

All answered must be typed using Times New Roman (size 12, double-spaced) font. No pictures…

3 years ago