The following code is an incorrect implementation of the bounded-buffer single producer and single consumer program. Pick three answers that are *CORRECT* in fixing the program to work even when the consumer and producer threads run simultaneously. #include #include #include #include #define BUFFER_SIZE 10#define COUNT 100int buffer;int in=0;int out=0;void enqueue(int data) { buffer=data; in = (in + 1) % BUFFER_SIZE;}int dequeue() { int data; data = buffer; out = (out + 1) % BUFFER_SIZE; return data;}void *producer(void *dummy) { int i=0; int count = (int) dummy; while(i < count) { enqueue(i++); printf("Producing value %d\n",i); } return NULL;}void *consumer(void *dummy) { int data; int count = (int) dummy; int i = 0; while(i < count) { data=dequeue(); printf("Consuming value %d\n",data); i++; } return NULL;}int main() { pthread_t tid; pthread_create(&tid,NULL,producer,(void *)COUNT); consumer((void *)COUNT); pthread_join(tid,NULL); return 0;}
According to the assignment, The Basics of Polymers, what ar…
According to the assignment, The Basics of Polymers, what are 3 things that you noticed? Your answers must be in the article or a comment by a classmate.
Da dove vieni? (city or nation or state) _______________
Da dove vieni? (city or nation or state) _______________
In the following equation, which element is reduced? H2S …
In the following equation, which element is reduced? H2S + HNO3 —> S + NO + H2O
ESSERE / AVERE. Which verb do you need to complete these par…
ESSERE / AVERE. Which verb do you need to complete these paragraphs, essere or avere? Choose the correct verb and then conjugate it in the present tense. These are the present tense conjugations of ESSERE and AVERE: sono, sei, è, siamo, siete, sono ho, hai, ha, abbiamo, avete, hanno
In the prototyping phase of an Arduino-based project, why is…
In the prototyping phase of an Arduino-based project, why is it important to test both an input and output component together before final assembly?
Single answer: xchgl is a x86 machine instruction that reads…
Single answer: xchgl is a x86 machine instruction that reads a 32bit value from a memory location and sets a new value to the same memory location as a single atomic instruction. The following xchg is the mutual exclusion (mutex) implemented in xv6 os kernel using a xchgl x86 instruction. For your understanding, the machine effects are described in C. static inline int xchg(volatile int *addr, int newval) { uint result; /* atomic read followed by update in a C version */ result = *addr; *addr = new; return result;} Select one that *CORRECTLY* implements a mutual lock to enter a critical section (mutual exclusion) using the xchg above.
WRITING. Answer the following questions. (Provide complete…
WRITING. Answer the following questions. (Provide complete sentences to earn full credit!)
Maria, posso usare ________________ telefono per favore?
Maria, posso usare ________________ telefono per favore?
Dolce → __________________ [CLOZE_01]
Dolce → __________________