PM
CMPE320 Final Exam questions and answers with
complete solutions verified latest update graded
a++ 2025/2026
Terms in this set (56)
shared data among heap data, code segment
threads in the same
process
returns old value parsed by old_ptr and
testAndSet() simultaneously updates said value to new
operations are performed atomically
builds a spin lock
test whether the value at the address specified
by ptr is equal to expected; if so update
compareAndSwap()
memory location to ptr with the new value,
if not do nothing
return original value at that memory location,
allowing the code to know whether the call
succeeded or not
parallelization task of transforming a single-threaded that does work
on multiple CPUs
threads independent tasks that call into various routines
critical section piece of code that accesses a shared
variable/resource and must not be
concurrency executed by more than one
thread
two or more processes reading/writing shared data, the
race condition/data race final result becomes
indeterminant, it's not known what the output
will be and is likely to be different across runs
mutual exclusion guarantees that if one thread is executing
within the critical section, the others will be
1/
7
, 7/7/25, 5:34
PM
prevented from doing so
useful instructions which can build a set of
synchronization multi-threaded code that accesses critical
primitives
sections in a synchronized and controlled
manner, reliably produces the correct
result despite concurrent execution
simplest type of lock to build, spins using CPU
cycles until the lock becomes available
spin lock requires a preemptive scheduler (scheduler
that will interrupt a thread via timer to run a
different thread)
really bad for CPU performance
yield() is called by a thread when it wants to
give up the CPU and let another thread run
yield lock a thread can be in 3 states: running, ready, blocked
yield() moves the caller from running to
ready, letting another thread run
yielding thread de-schedules itself
will a race condition no
always happen in a
critical section?
mutex name for a lock in the POSIX library, used to
provide mutual exclusion between threads
lock() return value returns 0 upon
meanings success error
number
otherwise
park() puts a calling thread to sleep
if the thread released a lock, the subsquent
wakeup/waiting race park called by the first thread would sleep
forever
avoided with setpark()
a thread can indicate that it is about to park, if
setpark() the thread is interrupted and another thread
calls un-park before park has actually been
2/
7