Complete the sentence to explain what a mutex lock does.
A mutex lock is used to [1] access to a shared resource.A mutex lock prevents simultaneous access to a shared resource, ensuring only one thread can use it at a time.
Complete the sentence to describe what happens when a thread tries to lock a mutex already locked by another thread.
If a thread tries to lock a mutex that is already locked, it will [1] until the mutex is unlocked.The thread will wait (block) until the mutex becomes available to ensure safe access.
Fix the error in the statement about mutex usage.
A thread must always [1] a mutex after finishing its work with the shared resource.
After finishing, a thread must unlock the mutex to allow others to access the resource.
Fill both blanks to complete the explanation of mutex behavior.
When a mutex is [1], other threads trying to [2] it will be blocked.
When a mutex is locked, other threads trying to lock it will be blocked until it is unlocked.
Fill all three blanks to complete the dictionary comprehension that maps thread IDs to their lock status if the mutex is locked.
status = { [1]: [2] for [3] in threads if mutex.is_locked() }This comprehension creates a dictionary with thread IDs as keys and their lock status as values when the mutex is locked.