0
0
Operating Systemsknowledge~10 mins

Mutex locks in Operating Systems - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the sentence to explain what a mutex lock does.

Operating Systems
A mutex lock is used to [1] access to a shared resource.
Drag options to blanks, or click blank then click option'
Aallow simultaneous
Bprevent simultaneous
Cignore
Dduplicate
Attempts:
3 left
💡 Hint
Common Mistakes
Thinking mutex allows multiple threads to access at the same time.
Confusing mutex with other synchronization tools.
2fill in blank
medium

Complete the sentence to describe what happens when a thread tries to lock a mutex already locked by another thread.

Operating Systems
If a thread tries to lock a mutex that is already locked, it will [1] until the mutex is unlocked.
Drag options to blanks, or click blank then click option'
Await
Bfail immediately
Cskip the lock
Dlock twice
Attempts:
3 left
💡 Hint
Common Mistakes
Assuming the thread can lock the mutex twice.
Thinking the thread fails immediately without waiting.
3fill in blank
hard

Fix the error in the statement about mutex usage.

Operating Systems
A thread must always [1] a mutex after finishing its work with the shared resource.
Drag options to blanks, or click blank then click option'
Aignore
Block
Cunlock
Dduplicate
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to unlock the mutex causing deadlocks.
Trying to lock the mutex again instead of unlocking.
4fill in blank
hard

Fill both blanks to complete the explanation of mutex behavior.

Operating Systems
When a mutex is [1], other threads trying to [2] it will be blocked.
Drag options to blanks, or click blank then click option'
Alocked
Bignore
Clock
Dunlock
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing locking and unlocking states.
Assuming threads ignore the mutex state.
5fill in blank
hard

Fill all three blanks to complete the dictionary comprehension that maps thread IDs to their lock status if the mutex is locked.

Operating Systems
status = { [1]: [2] for [3] in threads if mutex.is_locked() }
Drag options to blanks, or click blank then click option'
Athread_id
Blocked
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable for key and value incorrectly.
Not checking if the mutex is locked before creating the dictionary.