Also, this approach may have over-heads in frequent thread context switching reducing a system’s overall performance. Don’t block on locks, if a thread can’t acquire a lock, it should release previously acquired locks to try again laterĬumbersome to implement and can cause starvation ( Livelocks) where a thread is always letting locks go only to try again and do the same. Not possible where two operations need to be synchronized, example, a simple bank transfer, where you debit one account before you can credit the other account, and not let any other thread touch the balance in accounts until the current thread is done. Here are some of the theoretical solutions to Deadlocks, and one them (second one) is the main reason for Livelocks Theoretical Approaches Don’t use locks See below to understand how a aysnc-locking which is a strategy to avoid Deadlock can be the reason for a Livelock Livelocks occur when we try to avoid deadlocks using asynchronous locking, where multiple threads competing for the same set lock(s), avoid acquiring the lock(s) to allow other threads to go with the lock first, and eventually never get to acquire a lock and proceed causing starvation. #Livelock vs deadlock how toDeadlocks & Livelocks- How to avoid in real world Concurrency?ĭeadlocks can occur only in Concurrent (multi-threaded) programs where threads synchronize (use locks) access to one or more shared resources (variables and object) or instruction-set (critical-section).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |