if (0==fork()) {
printf("Child\n");
}
printf("Parent\n");
How many times is "Parent" printed? Why?
semaphore mutex=1; /* binary semaphore */
down(mutex);
down(mutex);
By the normal definition of binary semaphores, this results in deadlock.
But in this case, we want to allow multiple downs
by the same process. Define the operations down and
up permit multiple locks bt the same process without
deadlock.
// return unique id
int returnId(void) {
static int id=-1;
id++;
return id;
}
10K, 4K, 20K, 18K, 7K, 9K, 12K, 15KFor the sequence of requests
12K, 10K, 9KWhat is the allocation under first fit, best fit, worst fit, and next fit?