click below
click below
Normal Size Small Size show me how
CIsc361
the
| Question | Answer |
|---|---|
| A thread is a lightweight process that shares the same address space as other threads in the same process | |
| Creating a thread first guarantees that it will execute first | |
| A race condition occurs when the correctness of a program depends on the relative timing of threads | |
| he POSIX pthread_create function requires a function pointer that returns void* and accepts void* as an argument | |
| pthread_join waits for a specified thread to finish execution | |
| Returning a pointer to a stack variable from a thread is safe because each thread has its own stack | |
| Using pthread_create immediately followed by pthread_join is equivalent to a normal function call. | |
| Locks are used to protect critical sections from concurrent access | |
| Fine-grained locking can reduce parallelism compared to coarse-grained locking | |
| Using a simple integer variable and a while loop to implement a lock is correct because test and set happen atomically | |
| Spin locks waste CPU cycles while waiting for the lock to be released | |
| Disabling interrupts on a single CPU guarantees mutual exclusion |