CONCURRENCY AND SYNCHRONIZATION

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

what components do threads share?

code, heap, global/static variables, and file descriptors

2
New cards

what do threads not share?

registers, stack, and TCB

3
New cards

what is stored in each TCB:

thread id, state, priority, used register, stack location and pointer, local variables, program counter

4
New cards

what is a thread?

a unit of execution within a process

5
New cards

what is TCB?

a data struct inside the kernel that holds thread specific info

6
New cards

what does p_thread_join(thread_id) do?

it makes the main thread wait until the specified thread exits

7
New cards

what is a critical section?

what is progress? if no other thread is accessing a critical section, a thread will

A piece of code that access a shared resource

8
New cards

How do we avoid multiple threads accessing a shared resource at the same time?

ensure mutual exclusion, progress, and bounded wait

9
New cards

what is mutual exclusion?

condition that only one thread can access a critical section at a time

10
New cards

what is progress?

if no other thread is accessing a critical section, a thread will

11
New cards

what is bounded wait?

once a thread starts trying to enter a critical section, there is a count on the number of other threads that can enter before it does

12
New cards

what is race condition?

when results depend on the timing

13
New cards

what is a mutex?

a synchronization primitive that acts as a lock for a thread in a critical section

14
New cards

how would you make a mutex?

pthread_mutex name;

15
New cards

what is the purpose of pthread_mutex_create(&name)?

it makes a pointer to the mutex object

16
New cards

what is course grained locking:

one big lock used anytime when a critical section is accessed

17
New cards

what is fine grained locking:

different locks used for different resources

18
New cards

what advantage does fine grained locking give:

higher concurrency

19
New cards

what disadvantage does FGL give:

higher risk of deadlock

20
New cards

what is spinning:

when a thread is wasting time constantly checking a condition

21
New cards

what is a condition variable:

an explicit queue that threads can put themselves on when a condition isnt as desired

22
New cards

how do you declare a condition variable:

pthread_cond_t name;

23
New cards

what does pthread_cond_wait(&c,&m) do?

puts a thread in the condition variable c and releases the mutex m atomically

24
New cards

what does pthread_cond_signal(&c) do?

it wakes one thread waiting in the queue

25
New cards

why must you always hold the lock while signaling?

to prevent a race condition where it signals before a thread is put in queue

26
New cards

what is a monitor?

a structure that encapsulates both condition variable and mutex

27
New cards
28
New cards
29
New cards
30
New cards
31
New cards
32
New cards
33
New cards
34
New cards