Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are three mutex locks and different functions that use the locks. For the following cases, can the threads end up in a deadlock? If

image text in transcribed

There are three mutex locks and different functions that use the locks. For the following cases, can the threads end up in a deadlock? If a deadlock cannot occur, then explain which of the four required conditions for the deadlock is missing.

(1) Multiple threads concurrently calling functions 1 and 2.

(2) Multiple threads concurrently calling functions 3 and 4.

(3) Multiple threads concurrently calling functions 5 and 6.

(4) Multiple threads concurrently calling functions 1, 3, and 5.

(5) Multiple threads concurrently calling functions 1, 3, and 6.

Synchronization: deadlocks mutex_lock_t lock_a; mutex_lock_t lock_b; mutex_lock_t lock_c; void function_10 { LOCK (&lock_a); LOCK (&lock_b); UNLOCK (&lock_b); UNLOCK(lock_a); ) void function 20) { LOCK (&lock_b): LOCK (&lock_a); UNLOCK(&lock_a); UNLOCK(&lock_b): } void function 30) { int is locked - TRY_LOCK(Block_b); LOCK (&lock_c); UNLOCK(Slock_c); if (is_locked) (UNLDOK (&lock_b); } ) void function_40) int is locked - THY_LOCK(Block_c); LOCK (&lock_b); UNLOCK (&lock_b); if (is_locked) { UNLOCK (&lock_c); } ) void function 50) { int is locked; LOCK (&lock_c); is_locked - TRY_LOCK (&lock_a): if (is_locked) (UNLDOK (&lock_a); } UNLOCK (&lock_c); ) void function_60) int is locked; LOCK (&lock_a); LOCK (&lock_c); UNLOCK (Glock_c); UNLOCK(&lock_a); Synchronization: deadlocks mutex_lock_t lock_a; mutex_lock_t lock_b; mutex_lock_t lock_c; void function_10 { LOCK (&lock_a); LOCK (&lock_b); UNLOCK (&lock_b); UNLOCK(lock_a); ) void function 20) { LOCK (&lock_b): LOCK (&lock_a); UNLOCK(&lock_a); UNLOCK(&lock_b): } void function 30) { int is locked - TRY_LOCK(Block_b); LOCK (&lock_c); UNLOCK(Slock_c); if (is_locked) (UNLDOK (&lock_b); } ) void function_40) int is locked - THY_LOCK(Block_c); LOCK (&lock_b); UNLOCK (&lock_b); if (is_locked) { UNLOCK (&lock_c); } ) void function 50) { int is locked; LOCK (&lock_c); is_locked - TRY_LOCK (&lock_a): if (is_locked) (UNLDOK (&lock_a); } UNLOCK (&lock_c); ) void function_60) int is locked; LOCK (&lock_a); LOCK (&lock_c); UNLOCK (Glock_c); UNLOCK(&lock_a)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions