<span>void printArray(int a[ ]) {
</span> int i; <span>for (i = 0; i < a.length; i++){
</span> <span>System.out.print(a[i]);
</span> System.out.println(); <span>}
</span> }
The computer was invented by <span>Tom Warburton.</span>
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.
The answer would be true. They're notes, so you don't need it to be written perfectly.
Edit: How would this be incorrect? A study guide is a personal thing, and so are notes. So long as you understand the notes, they don't need to be written as perfectly as an essay would.
Answer:
Yes, but if you click on your history you can see all of what you went on for a few days back
Explanation: