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 23:30
Acomputer is a multipurpose device that accepts input, processes data, stores data, and produces output, all according to a series of stored . the processing unit of most modern computers is a(n) . the instructions that tell a computer how to carry out a task are referred to as computer , which are distributed as software. computers run three main types of software: software, system software, and development tools. an example of system software is a computer system, which is essentially the master controller for all the activities that a digital device performs. digital devices are constructed using tiny electronic components that represent data bits as electrical signals. the system unit houses the system board, which contains several circuits made from semiconducting materials. computers come in three popular form factors: component, , and slate. many of today's digital devices operate on battery power supplied by ion batteries. battery life and lifespan can be extended by following good battery management practices.
Answers: 3
question
Computers and Technology, 22.06.2019 15:30
In a compound condition, both conditions on either side of the logical operator and must be true for the overall condition to be true. a: true b: false
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
What is the main benefit of minimizing the ribbon in word? more options will be accessible through customized keystrokes. more of the document will be viewable without needing to scroll. fewer controls will be accessible to the user by using the mouse. fewer editing options will be available without entering a password.
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
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, 20.10.2020 01:01
question
World Languages, 20.10.2020 01:01
question
Mathematics, 20.10.2020 01:01
question
Mathematics, 20.10.2020 01:01
Questions on the website: 13722367