1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ryzh [129]
3 years ago
7

The producer thread will alternate between sleeping for a random period of time and inserting a random integer into the buffer.

Random numbers will be produced using the rand_r(unsigned int *seed) function, which produces random integers between 0 and RAND_MAX safely in multithreaded processes. The consumer will also sleep for a random period of time and, upon awakening, will attempt to remove an item from the buffer. An outline of the producer and consumer threads appears as:
Computers and Technology
1 answer:
Llana [10]3 years ago
3 0

Answer:

// Producer Thread

void *producer(void *param) {

buffer_item item;

while (true) {

item = rand() % 100;

sem_wait(&empty);

pthread_mutex_lock(&mutex);

if (insert_item(item))

printf("Can't insert item\n");

else

printf("Producer %d: produced %d\n", *((int*)param), item);

pthread_mutex_unlock(&mutex);

sem_post(&full);

}

}

// Consumer Thread

void *consumer(void *param) {

while (true) {

buffer_item item = NULL;

if (in > 0)

item = buffer[in - 1];

sem_wait(&full);

pthread_mutex_lock(&mutex);

if (remove_item(&item))

printf("Can't remove item\n");

else

printf("Consumer %d: consumed %d\n", *((int*)param), item);

pthread_mutex_unlock(&mutex);

sem_post(&empty);

}

}

Explanation:

An outline of the producer and consumer threads appears as shown above.

You might be interested in
Which is the most used operating system? A. Windows B.Linux C.Leopard D. DOS
Neko [114]
I think it´s either A. or  B.
7 0
3 years ago
Read 2 more answers
By far, the largest social network for gaming is:answer twitter. linkedin. myspace. facebook. youtube
Firdavs [7]
<span>By far, the largest social network for gaming is Facebook. The correct option among all the options that are given in the question is the fourth option or the penultimate option. Facebook is also the most popular social networking website around the world. I hope that this is the answer that has come to your help.</span>
7 0
3 years ago
After a customer buys a computer or receives service from Top Computers and Service, a service representative contacts each cust
AlladinOne [14]

Answer: False

Explanation:

 The given statement is false, as the survey information basically represent feedback in which the service representative contact each and every customers to collect the feedback.

Feedback is in the form of information in which it represent the reaction in the scenario to the output but it basically affects as an input. Therefore, the survey information is in the form of input not as output.

7 0
3 years ago
Your mother is sure that you were driving too fast because she knows
Klio2033 [76]

I think the corret answer would be C

5 0
3 years ago
Read 2 more answers
A__ is a part of a GUI that allows a specific type of interaction with the user.
rosijanka [135]

The part of a graphic user interface (GUI) that allows a specific type of interaction with an end user is: D. widget.

<h3>What is a widget?</h3>

A widget is sometimes referred to as a gadget and it can be defined as a software application that is designed and developed as a part (element) of a graphic user interface (GUI) to display specific information or provide an end user with a specific way to interact with the computer's operating system (OS) or program.

<h3>The examples of a widget.</h3>

In Computer science, there are different types of widget and these include the following:

  • Search box widgets
  • Clock widgets
  • Weather widgets
  • Calculator widgets
  • Stock market widgets

In conclusion, the part of a graphic user interface (GUI) that allows a specific type of interaction with an end user is a widget.

Read more on widget here: brainly.com/question/7498108

4 0
3 years ago
Other questions:
  • Caracteristicas de los valores numericos en excel
    14·1 answer
  • On a wireless router, what gives out IP addresses?<br> DHCP<br> DNS<br> WPA<br> WPS
    10·1 answer
  • Categories of general purpose application software and examples each​
    13·1 answer
  • In the design phase of the systems development life cycle (SDLC), the _____ design is an overview of the system and does not inc
    10·1 answer
  • E-governance is the only solution against corruption. justify the statement in context of nepal​
    13·1 answer
  • Design the following webpage using suitable html code .
    11·2 answers
  • While using a web-based order form, an attacker enters an unusually large value in the Quantity field. The value he or she enter
    15·1 answer
  • In a word-processing program, what are the easily accessible icons that allow you to print, save and change fonts with a click o
    8·1 answer
  • PLS HURRY<br> Look at the image below
    8·1 answer
  • Var words = ["apple", "bug","car", "dream", "ear", "food"]
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!