Changeset 48fda7a for doc/theses
- Timestamp:
- Apr 2, 2023, 8:21:07 AM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 9a5a2cd
- Parents:
- fb7cda9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex
rfb7cda9 r48fda7a 41 41 The mutex statement uses the deadlock prevention technique of lock ordering, where the circular-wait condition of a deadlock cannot occur if all locks are acquired in the same order. The scoped\_lock uses a deadlock avoidance algorithm where all locks after the first are acquired using \code{try_lock} and if any of the attempts to lock fails, all locks so far are released. This repeats until all locks are acquired successfully. The deadlock avoidance algorithm used by scoped\_lock is shown in Listing~\ref{l:cc_deadlock_avoid}. The algorithm presented is taken directly from the source code of the \code{<mutex>} header, with some renaming and comments for clarity. 42 42 43 \begin{cppcode}[ tabsize=3,caption={\CC scoped\_lock deadlock avoidance algorithm},label={l:cc_deadlock_avoid}]43 \begin{cppcode}[caption={\CC scoped\_lock deadlock avoidance algorithm},label={l:cc_deadlock_avoid}] 44 44 int first = 0; // first lock to attempt to lock 45 45 do {
Note: See TracChangeset
for help on using the changeset viewer.