subject

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 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, list1);
}
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);
}
Using the POSIX library, rewrite the code for the threads, using semaphores to implement the necessary mutual exclusion and synchronization. The solution must be deadlock-free and concurrency should not be unnecessarily restricted.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:20
Quincy would like to view the contents of a specific message in his inbox. a portion of his computer screen is shown. what should quincy do in order to complete this task? 1. click on the inbox in the navigation pane, and click on the specific message in the folder pane to display its contents. 2. click on the inbox in the outlook today window, and click on the specific message in the folder pane to display its contents. 3. double-click the message’s header in the outlook today window, and right-click on the specific message to display its contents. 4. double-click the mail option in the navigation pane, and right-click on the specific message to display its contents.
Answers: 1
question
Computers and Technology, 22.06.2019 21:00
Kirk found a local community college with a two-year program and he is comparing the cost with that of an out-of-state two-year school. what is the expected total cost for one year at the local community college if kirk lives at home? what is the expected total cost for one year at the out-of-state school if kirk lives on campus?
Answers: 2
question
Computers and Technology, 23.06.2019 13:30
Stops: using the information learned in this course, explain three things you will not do when driving. a. b. c. explain why you will not do these things when driving. starts: using the information learned in this course, explain three things you will do when driving. a. b. c. explain why you will do these particular things when driving. explain one thing you will stop doing as a passenger. explain one thing you will start doing as a passenger.
Answers: 3
question
Computers and Technology, 23.06.2019 18:40
How does is make you feel when you're kind to others? what are some opportunities in your life to be more kind to your friends and loved ones? imagine a world where kindness has be outlawed. how would people act differently? would your day-to-day life change significantly? why or why not?
Answers: 2
You know the right answer?
Consider a system with N blocks of storage, each of which holds one unit of information (e. g. an in...
Questions
question
English, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
History, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Geography, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
English, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
question
English, 10.09.2020 14:01
question
Mathematics, 10.09.2020 14:01
Questions on the website: 13722363