Lines Matching full:mutex
3 * Module Name: exmutex - ASL Mutex Acquire/Release functions
172 * PARAMETERS: ObjDesc - The mutex to be unlinked
176 * DESCRIPTION: Remove a mutex from the "AcquiredMutex" list
184 ACPI_THREAD_STATE *Thread = ObjDesc->Mutex.OwnerThread;
194 if (ObjDesc->Mutex.Next)
196 (ObjDesc->Mutex.Next)->Mutex.Prev = ObjDesc->Mutex.Prev;
199 if (ObjDesc->Mutex.Prev)
201 (ObjDesc->Mutex.Prev)->Mutex.Next = ObjDesc->Mutex.Next;
204 * Migrate the previous sync level associated with this mutex to
205 * the previous mutex on the list so that it may be preserved.
209 (ObjDesc->Mutex.Prev)->Mutex.OriginalSyncLevel =
210 ObjDesc->Mutex.OriginalSyncLevel;
214 Thread->AcquiredMutexList = ObjDesc->Mutex.Next;
223 * PARAMETERS: ObjDesc - The mutex to be linked
228 * DESCRIPTION: Add a mutex to the "AcquiredMutex" list for this walk
244 ObjDesc->Mutex.Prev = NULL;
245 ObjDesc->Mutex.Next = ListHead;
251 ListHead->Mutex.Prev = ObjDesc;
265 * ObjDesc - Mutex object
270 * DESCRIPTION: Acquire an AML mutex, low-level interface. Provides a common
273 * MUTEX: Interpreter must be locked
302 if (ObjDesc->Mutex.ThreadId == ThreadId)
305 * The mutex is already owned by this thread, just increment the
308 ObjDesc->Mutex.AcquisitionDepth++;
312 /* Acquire the mutex, wait if necessary. Special case for Global Lock */
320 Status = AcpiExSystemWaitMutex (ObjDesc->Mutex.OsMutex, Timeout);
330 /* Acquired the mutex: update mutex object */
332 ObjDesc->Mutex.ThreadId = ThreadId;
333 ObjDesc->Mutex.AcquisitionDepth = 1;
334 ObjDesc->Mutex.OriginalSyncLevel = 0;
335 ObjDesc->Mutex.OwnerThread = NULL; /* Used only for AML Acquire() */
346 * ObjDesc - Mutex object
351 * DESCRIPTION: Acquire an AML mutex
377 "Cannot acquire Mutex [%4.4s], null thread info",
378 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
384 * of the mutex. This mechanism provides some deadlock prevention.
386 if (WalkState->Thread->CurrentSyncLevel > ObjDesc->Mutex.SyncLevel)
389 "Cannot acquire Mutex [%4.4s], "
391 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
397 "Acquiring: Mutex SyncLevel %u, Thread SyncLevel %u, "
399 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
400 ObjDesc->Mutex.AcquisitionDepth, WalkState->Thread));
405 if (ACPI_SUCCESS (Status) && ObjDesc->Mutex.AcquisitionDepth == 1)
409 ObjDesc->Mutex.OwnerThread = WalkState->Thread;
410 ObjDesc->Mutex.OriginalSyncLevel =
413 ObjDesc->Mutex.SyncLevel;
415 /* Link the mutex to the current thread for force-unlock at method exit */
421 "Acquired: Mutex SyncLevel %u, Thread SyncLevel %u, Depth %u\n",
422 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
423 ObjDesc->Mutex.AcquisitionDepth));
437 * DESCRIPTION: Release a previously acquired Mutex, low level interface.
441 * MUTEX: Interpreter must be locked
461 if (ObjDesc->Mutex.AcquisitionDepth == 0)
468 ObjDesc->Mutex.AcquisitionDepth--;
469 if (ObjDesc->Mutex.AcquisitionDepth != 0)
476 if (ObjDesc->Mutex.OwnerThread)
478 /* Unlink the mutex from the owner's list */
481 ObjDesc->Mutex.OwnerThread = NULL;
484 /* Release the mutex, special case for Global Lock */
492 AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
495 /* Clear mutex info */
497 ObjDesc->Mutex.ThreadId = 0;
511 * DESCRIPTION: Release a previously acquired Mutex.
533 OwnerThread = ObjDesc->Mutex.OwnerThread;
535 /* The mutex must have been previously acquired in order to release it */
540 "Cannot release Mutex [%4.4s], not acquired",
541 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
550 "Cannot release Mutex [%4.4s], null thread info",
551 AcpiUtGetNodeName (ObjDesc->Mutex.Node)));
556 * The Mutex is owned, but this thread must be the owner.
563 "Thread %u cannot release Mutex [%4.4s] acquired by thread %u",
565 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
571 * The sync level of the mutex must be equal to the current sync level. In
572 * other words, the current level means that at least one mutex at that
573 * level is currently being held. Attempting to release a mutex of a
574 * different level can only mean that the mutex ordering rule is being
577 if (ObjDesc->Mutex.SyncLevel != OwnerThread->CurrentSyncLevel)
580 "Cannot release Mutex [%4.4s], SyncLevel mismatch: "
581 "mutex %u current %u",
582 AcpiUtGetNodeName (ObjDesc->Mutex.Node),
583 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel));
588 * Get the previous SyncLevel from the head of the acquired mutex list.
593 OwnerThread->AcquiredMutexList->Mutex.OriginalSyncLevel;
598 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
599 PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth,
608 if (ObjDesc->Mutex.AcquisitionDepth == 0)
618 ObjDesc->Mutex.SyncLevel, WalkState->Thread->CurrentSyncLevel,
619 PreviousSyncLevel, ObjDesc->Mutex.AcquisitionDepth));
638 * method to acquire a mutex, and a different method to release it, as long as
660 "Mutex [%4.4s] force-release, SyncLevel %u Depth %u\n",
661 ObjDesc->Mutex.Node->Name.Ascii, ObjDesc->Mutex.SyncLevel,
662 ObjDesc->Mutex.AcquisitionDepth));
664 /* Release the mutex, special case for Global Lock */
674 AcpiOsReleaseMutex (ObjDesc->Mutex.OsMutex);
677 /* Update Thread SyncLevel (Last mutex is the important one) */
679 Thread->CurrentSyncLevel = ObjDesc->Mutex.OriginalSyncLevel;
681 /* Mark mutex unowned */
683 Next = ObjDesc->Mutex.Next;
685 ObjDesc->Mutex.Prev = NULL;
686 ObjDesc->Mutex.Next = NULL;
687 ObjDesc->Mutex.AcquisitionDepth = 0;
688 ObjDesc->Mutex.OwnerThread = NULL;
689 ObjDesc->Mutex.ThreadId = 0;