Graded Quiz Unit 3 Attempt Review PDF
Graded Quiz Unit 3 Attempt Review PDF
Graded Quiz Unit 3 Attempt Review PDF
True or False: Lookups simply read the data structure; as long as we can guarantee
that no insert is on-going, we can allow many lookups to proceed concurrently.
Select one:
True
False
/
Question 2 Correct Mark 1.00 out of 1.00
True or False: Condition variable is an explicit queue that threads can put
themselves on when some state of execution (i.e., some condition) is not as desired
by waiting on the condition.
Select one:
True
False
True or False: To use a condition variable, one has to in addition have a lock that is
not associated with this condition.
Select one:
True
False
True or False: In a multi-threaded application, the developer has full control over
what is scheduled at a given moment in time; rather, the programmer simply
creates threads and then hopes that the underlying OS schedules them in a
reasonable manner across available CPUs.
Select one:
True
False
/
Question 5 Correct Mark 1.00 out of 1.00
Thread 1: Thread 2:
lock(L1); lock(L2);
lock(L2); lock(L1);
Select one:
c. Thread 1 grabs lock L1 and then a context switch occurs to Thread 2, then Thread 2
grabs L2 and tries to acquire L1
The correct answer is: Thread 1 grabs lock L1 and then a context switch occurs to Thread 2,
then Thread 2 grabs L2 and tries to acquire L1
True or False: Atomicity violation bugs and order violation bugs are examples of
Non-deadlock bugs.
Select one:
True
False
/
Question 7 Correct Mark 1.00 out of 1.00
POSIX threads library are those for providing mutual exclusion to a critical section
via:
Select one:
a. API’s
b. Multi-threaded
c. locks
d. Keys
True or False: Concurrent data structures can be queues lists and counters only.
Select one:
True
False
/
Question 9 Correct Mark 1.00 out of 1.00
What command would you change to switch the letter printed by T2:
Time increases in the downwards direction, and each column shows when a
di erent thread (the main one, or T1, or T2) is running:
Select one:
a. T1 = T2
c. T2 prints “A”
d. T2 = T1
/
Question 10 Correct Mark 1.00 out of 1.00
Thread 0 holds the lock (i.e., it has called sem wait() but not yet called sem post()),
and another thread (thread 1, say) tries to enter the critical section by calling sem
wait(). In this case thread 1 must wait (putting itself to sleep and relinquishing the
processor)?
Select one:
The correct answer is: thread 1will nd that the value of the semaphore is 0
Select one:
a. Stack (1)
b. Stack (3)
c. Program code
d. Free
/
Question 12 Correct Mark 1.00 out of 1.00
Select one:
a. API poll ()
b. API select ()
c. Select
d. Poll
Select one:
a. Mutual Exclusion
b. Non-Critical Section
c. Race Condition
d. Intermediate
/
Question 14 Correct Mark 1.00 out of 1.00
Select one:
a. Simple
b. Correct
c. Fair
d. Perform
Select one:
a. TCB
b. PCB
c. T1
d. T2
/
Question 16 Correct Mark 1.00 out of 1.00
What capability allows multiple people to use one system at the same time?
Select one:
a. Multi-thread
b. Multi-user
c. Distributed Processing
d. Multitasking
True or False: Locks work through mutual exclusion which preventing multiple
threads from entering a critical section.
Select one:
True
False
/
Question 18 Correct Mark 1.00 out of 1.00
Imagine two producers (Pa and Pb) both calling into put() at roughly the same time.
Assume producer Pa gets to run rst, and just starts to ll the rst bu er entry ( ll
= 0 at line f1). Before Pa gets a chance to increment the ll counter to 1, it is
interrupted. Producer Pb starts to run, and at line f1 it also puts its data into the
0th element of bu er, what happens to the old data?
sem_t empty;
sem_t full;
void *producer(void *arg) {
int i;
for (i = 0; i < loops; i++) {
sem_wait(&empty); // line p1
put(i); // line p2
sem_post(&full); // line p3
}
}
void *consumer(void *arg) {
int i, tmp = 0;
while (tmp != -1) {
sem_wait(&full); // line c1
tmp = get(); // line c2
sem_post(&empty); // line c3
printf("%d\n", tmp);
}
}
int main(int argc, char *argv[]) {
// ...
sem_init(&empty, 0, MAX); // MAX bu ers are empty to begin with...
sem_init(&full, 0, 0); // ... and 0 are full
// ...
}
Select one:
a. Backed up
b. Saved
c. Overwritten
d. Value = 0
e
while (1) {
events = getEvents();
for (x in events)
processEvent(x);
}:
Select one:
a. e
b. 1
c. x
d. Null
/
Question 20 Correct Mark 1.00 out of 1.00
/
pthread_mutex_unlock(&L->lock);
return -1; // failure
}
Select one:
b. pthread_mutex_unlock(&L->lock)
c. Acquires a lock in the insert routine upon entry, and only releases it on condition
d. Acquires a lock in the insert routine upon entry, and only releases it on exit
The correct answer is: Acquires a lock in the insert routine upon entry, and only releases it
on exit
◄ Self-Quiz Unit 3
Jump to...