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.
Answer:
i think Make variables to represent the length and width of a rectangle, called length
and width
, respectively. You should set length
to 10 and width
to 5.
Then, write some mathematical expressions to computer the area and perimeter of the rectangle and save these values inside variables named area and perimeter
.Use print
statements to display the area and perimeter of the rectangle.
Your output should print the area on the first line and the perimeter on the second, like this:
50 30 Rectangle Area Formula:
Area = L * W
Explanation:
Answer:
The digital footprint that is had behind can have repercussions in every aspect of your adolescent's life, conceivably bringing about botched occupation chances, public sharing of individual data, destroyed connections
Explanation:
Digital trail what's left behind as you calmly peruse the web, post via web-based media or even sort into a visit administration. Regardless of whether you're mindful, you add to your advanced impression or profile every day when you sign onto the Internet. The sites you visit, the news posts you remark on, the remarks you leave via web-based media stages—every one of these things meet up to make a representation of your online life.
The digital footprint that is had behind can have repercussions in every aspect of your adolescent's life, conceivably bringing about botched occupation chances, public sharing of individual data, destroyed connections — or, in what is likely more pertinent to them at this moment: Their folks discovering what they've been up to and along these lines being rebuffed.
Answer:
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"enter the value of a:";
cin>>a;
cout<<"enter the value of b:";
cin>>b;
cout<<"enter the value of c:";
cin>>c;
cout<<"product is:"<<(a*b*c);
return 0;
}
Explanation: