Quiz 8 Flashcards

1
Q

An approximate counter represents a logical counter via multiple local physical counters.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a condition variable?

Just another name for a lock

A queue that allows threads to wait for a condition to become true

A flag that describes whether multiprocessing is enabled

A flag that describes if multiple threads are running

A

A queue that allows threads to wait for a condition to become true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Semaphores cannot be used to enforce an order in the execution of different threads

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Select all the statements that apply to semaphores

A semaphore can be used to synchronize threads or processes

A semaphore can be manipulated via lock and a unlock routines

A semaphore can be manipulated via post and a wait routines

A semaphore’s value is always initialized to 1

A

Correct Answer
A semaphore can be used to synchronize threads or processes

Correct Answer
A semaphore can be manipulated via post and a wait routines

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Thread ________ is a technique used to prevent too many threads from concurrently performing a given task.

A

throttling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Which concurrency bug occurs here?

THREAD 1: if (record->uid) printf(“%s\n”, record->uid);

THREAD 2: record->uid = NULL;

No bug occurs

Use after free

Deadlock

Atomicity violation

A

Atomicity violation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which primitives can be used to implement a lock? Mark all that applies

fetch and add
vpn-to-pfn
compare-and-swap
test-and-set

A

fetch and add
compare-and-swap
test-and-set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Consider a multi-threaded counter implementation which uses a lock to protect the instructions incrementing the counter. This is an efficient way to implement a multi-threaded counter.

(true or false)

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A fetch-and- ____ instruction increments a value, while returning the old value at a particular memory location

A

add

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a deadlock?

A task which cannot benefit from concurrent execution

A type of lock in which waiting threads are de-scheduled

A situation where a thread terminates without de-initialize a lock

A situation where multiple threads are stuck waiting for each other to release a resource

A

A situation where multiple threads are stuck waiting for each other to release a resource

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Semaphores can be used to implement both locks and condition variables

(True or False)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

A ____ -and-swap instruction compares a value in memory with an expected value, and if equal updates the memory with a new value.

A

compare

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the producer-consumer problem describe?

A situation where one producer thread places items in a buffer, and one consumer thread processes them

A situation where one or more consumer threads place items in a buffer, and one or more producer threads process them

A situation where one or more producer threads place items in a buffer, and one or more consumer threads process them

A situation where one consumer thread places items in a buffer, and one or more producer thread processes them

A

A situation where one or more producer threads place items in a buffer, and one or more consumer threads process them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A ticket lock guarantees that all threads that attempt to acquire it will eventually succeed

(True or false)

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A data structure is thread safe if multiple threads will never try to access it concurrently

(True or false)

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly