Synchronization Tools Flashcards
Why do processes and threads cooperate with each other? (3 things)
- information sharing
- computation speed up
- Modularity
Data can be shared with _____ ______ or _______ ________
shared memory, message passing
In shared memory, process A ____ shared memory, process B _____ this memory to their own _____ space and then is treated as ______ memory
creates, attaches, address, regular
In shared memory, ________ is needed to coordinate conflicting accesses
synchronization
POSIX APIs to shared memory synchronization include ______, _____ and ____
shm_open, shm_at, mmap
In message passing, process A sends message to B via _______
kernel
In message passing, processes can ____ for the message to be delivered
wait
The pros of shared memory is ______ and _______
speed, convenience
The cons of shared memory is having to ______ conflicts
manage
The pros of message passing is that there is no ______ and it is easy to _____ messages
conflict, exchange
The cons of message passing include high _______, ______ involvement, and the usage of several ______
overhead, kernel, syscalls
In the producer consumer problem, 2 _______ share a _______
threads, buffer
In the producer consumer problem, the producer places ______ into the buffer and must wait if it is ____
items, full
In the producer consumer problem, the consumer _____ items from the buffer and must wait if it is _____
takes, empty
In the producer consumer problem, we can coordinate producer and consumer by keeping a ______ on the # of items in the buffer
counter
In the producer consumer problem, how is count++ implemented?
register1 = count register1 = register1 + 1 count = register1
In the producer consumer problem, how is count– implemented?
register2 = count register2 = register2 -1 count = register2
In the producer consumer problem, consumers and producers run on the ____ core or _______ cores in parallel
same, different
In the producer consumer problem, the CPU scheduler can switch between producer and consumer at ___ time
any
In the producer consumer problem, when can the counter start at 6, call count++, call count–, and end up at 7?
When the CPU decides to swap the process to the consumer and finish the consumer process before the producer finishes
What is a race condition?
When multiple processes manipulate shared data concurrently and the result depends on the order of manipulation
A ______ _____ is code that manipulates shared data
critical section
To handle race conditions, make sure that when one _______ is executing the __, no other processes can
process, CS
What 3 requirements must be satisfied for a solution the CS problem?
- Mutual Exclusion
- Progress
- Bounded Waiting
Mutual Exclusion makes sure there is only ____ thread allows in the CS
one
Progress means that the thread should eventually _______
complete