Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

osatomicdequeue(3) [mojave man page]

ATOMIC(3)						   BSD Library Functions Manual 						 ATOMIC(3)

NAME
OSAtomicEnqueue, OSAtomicDequeue -- atomic lockless queues SYNOPSIS
#include <libkern/OSAtomic.h> void OSAtomicEnqueue(OSQueueHead *list, void *new, size_t offset); void* OSAtomicDequeue(OSQueueHead *list, size_t offset); DESCRIPTION
The 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. EXAMPLES
typedef 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 VALUES
The dequeue operation returns the most recently enqueued element, or NULL if the list in empty. SEE ALSO
stdatomic(3), atomic_deprecated(3), spinlock_deprecated(3) HISTORY
These functions first appeared in Mac OS 10.5 (Leopard). Darwin May 26, 2004 Darwin

Check Out this Related Man Page

ATOMIC(3)						   BSD Library Functions Manual 						 ATOMIC(3)

NAME
OSAtomicEnqueue, OSAtomicDequeue -- atomic lockless queues SYNOPSIS
#include <libkern/OSAtomic.h> void OSAtomicEnqueue(OSQueueHead *list, void *new, size_t offset); void* OSAtomicDequeue(OSQueueHead *list, size_t offset); DESCRIPTION
The 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. EXAMPLES
typedef 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 VALUES
The dequeue operation returns the most recently enqueued element, or NULL if the list in empty. SEE ALSO
stdatomic(3), atomic_deprecated(3), spinlock_deprecated(3) HISTORY
These functions first appeared in Mac OS 10.5 (Leopard). Darwin May 26, 2004 Darwin
Man Page

3 More Discussions You Might Find Interesting

1. Programming

error in managing linklist

I have used link list in my program to operate on set of values the operations that i am doing : add , delete from link list when i am deleting the intermidiate or last value it is not giving any error but when i am deleting the 1 st value then program hangs can anyone suggest me the reason (3 Replies)
Discussion started by: bhakti_2025
3 Replies

2. OS X (Apple)

Vi in Leopard

I read last night in MacWorld that Leopard included a new version of vi. Is there a list somewhere of the changes? I use vi a lot. Gale (5 Replies)
Discussion started by: Gale Gorman
5 Replies

3. AIX

Grep multiple lines and redirect to file

I have setof files with data and with same fields multiple times in each of the files. for example: file 1 name = mary kate last name = kate address = 123 street = abc name = mary mark last name = mark address = 456 street = bcd file 2 name = mary kate last name = kate... (2 Replies)
Discussion started by: relearner
2 Replies