Quiz 7 Flashcards

1
Q

What is thread local storage?

A

The stack of a thread

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

Spinlocks work quite well on multi-CPU systems

A

True

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

in programming, a race condition is an error that happens when a program finishes early than expected.

(true or false)

A

False

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

When using POSIX threads, what is the correct way to initiate a new thread?

pthread_start()

pthread_create()

pthread_run()

pthread_init()

A

pthread_create()

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

Does pthread_create() return anything?

No, because pthread_create() is not a function

Yes, but only on failure

Yes, it always return an integer value

No, because after it executes the content of the text segment is overwritten

A

Yes, it always return an integer value

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

What is a thread?

Just another name for process

A parallel algorithm

A library to enable process to communicate

A multiprogramming abstraction within a single process

A

A multiprogramming abstraction within a single process

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

A test-and- ______ instruction returns the old value of a variable while simultaneously updating it to a new value

A

set

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

The code below is correct

pthread_mutex_t lock;
pthread_mutex_lock(&lock);
x = x + 1;
pthread_mutex_unlock(&lock);

A

False

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

Multiple threads within a process can share data

True
False
A

True

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

What is the code below doing?

pthread_mutex_lock(&lock);

balance = balance + 1;

pthread_mutex_unlock(&lock);

Choices:
Creating a new thread and waiting for it to terminate

Using a lock to protect a critical section

Measuring how many times the thread loops while waiting to acquire the lock

Freeing the memory used to create a lock

A

Using a lock to protect a critical section

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

Threads allow to parallelize computation within a single process

A

True

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

What is a critical section?
Choices

A sequence of instructions which is likely to crash a program

A piece of code that must not be executed concurrently by more than one thread

A data structure used for communication between threads

Another name for thread

A

A piece of code that must not be executed concurrently by more than one thread

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

Interrupting an atomic instruction does not leave the CPU in an undefined state

(true or false)

A

true

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

One way to implement critical sections on a single-processor system is to simply disable interrupt. Is this approach practical?

Choices:
No, because there is no way to disable interrupts on such a system

Yes, because it is so simple that it is impossible to get it wrong

No, because it gives threads too many privileges (the ability to disable interrupt)

Yes, because it can be performed efficiently

A

No, because it gives threads too many privileges (the ability to disable interrupt)

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

What are the criteria used to judge the quality of a lock implementation? Select all that applies

Correctness

Performance

Fairness

Obsolescence

A

Correctness

Performance

Fairness

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