PFUNC  1.0
Defines | Functions
pfunc/futex.h File Reference
#include <sys/syscall.h>
#include <unistd.h>
#include <errno.h>
#include <pfunc/environ.hpp>

Go to the source code of this file.

Defines

#define SYS_futex   202
#define FUTEX_WAIT   0
#define FUTEX_WAKE   1

Functions

static PFUNC_INLINE void futex_wait (int *addr, int val)
 Atomically checks if the value at the given address is what is expected. If so, the the calling thread is put to sleep waiting on a futex_wake call to occur. If the value at the address has changed, the calling thread returns without entering the kernel.
static PFUNC_INLINE void futex_wake (int *addr, int nthreads)
 Wakes up the specified number of threads which are sleeping on using futex_wait at the given address.
static PFUNC_INLINE void cpu_relax (void)
 Performs a nop -- basically a way to ensure we are not using memory.

Define Documentation

#define FUTEX_WAIT   0
#define FUTEX_WAKE   1
#define SYS_futex   202

Function Documentation

static PFUNC_INLINE void cpu_relax ( void  ) [static]

Performs a nop -- basically a way to ensure we are not using memory.

Do nothing as of now

static PFUNC_INLINE void futex_wait ( int *  addr,
int  val 
) [static]

Atomically checks if the value at the given address is what is expected. If so, the the calling thread is put to sleep waiting on a futex_wake call to occur. If the value at the address has changed, the calling thread returns without entering the kernel.

Parameters:
[in]addrAddress at which the value needs to be checked.
[in]valThe value if found at the given address, the sleep should be entering.
static PFUNC_INLINE void futex_wake ( int *  addr,
int  nthreads 
) [static]

Wakes up the specified number of threads which are sleeping on using futex_wait at the given address.

Parameters:
[in]addrAddress at which the threads are waiting.
[in]nthreadsThe number of threads to wake up.