Query: osatomicenqueue
OS: mojave
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
ATOMIC(3) BSD Library Functions Manual ATOMIC(3)NAMEOSAtomicEnqueue, OSAtomicDequeue -- atomic lockless queuesSYNOPSIS#include <libkern/OSAtomic.h> void OSAtomicEnqueue(OSQueueHead *list, void *new, size_t offset); void* OSAtomicDequeue(OSQueueHead *list, size_t offset);DESCRIPTIONThe routines OSAtomicEnqueue() and OSAtomicDequeue() operate on singly linked LIFO queues. Ie, a dequeue operation will return the most recently enqueued element, or NULL if the list is empty. The operations are lockless, and barriers are used as necessary to permit thread- safe access to the queue element. offset is the offset in bytes to the link field in the queue element. Important: the memory backing the link field of a queue element must not be unmapped after OSAtomicDequeue() returns until all concurrent calls to OSAtomicDequeue() for the same list on other threads have also returned, as they may still be accessing that memory location.EXAMPLEStypedef struct elem { long data1; struct elem *link; int data2; } elem_t; elem_t fred, mary, *p; OSQueueHead q = OS_ATOMIC_QUEUE_INIT; OSAtomicEnqueue( &q, &fred, offsetof(elem_t,link) ); OSAtomicEnqueue( &q, &mary, offsetof(elem_t,link) ); p = OSAtomicDequeue( &q, offsetof(elem_t,link) ); In this example, the call of OSAtomicDequeue() will return a ptr to mary.RETURN VALUESThe dequeue operation returns the most recently enqueued element, or NULL if the list in empty.SEE ALSOstdatomic(3), atomic_deprecated(3), spinlock_deprecated(3)HISTORYThese functions first appeared in Mac OS 10.5 (Leopard). Darwin May 26, 2004 Darwin
Related Man Pages |
---|
osatomicincrement32(3) - osx |
osatomicadd32barrier(3) - osx |
osatomicadd32(3) - osx |
osatomicand32orig(3) - osx |
osatomiccompareandswap32barrier(3) - osx |
Similar Topics in the Unix Linux Community |
---|
error in managing linklist |
Leopard is now certified Unix, but is it safe? - Computerworld New Zealand |
Vi in Leopard |
Grep multiple lines and redirect to file |