92 deadline =
uptime + timeout;
95 bool firstCheck =
true;
113 if (loadedVal != val)
128 LOG_DEBUG(
"futex wait interrupted tid=%d\n", thread->
id);
#define SYSCALL_DEFINE(num, returnType,...)
Macro to define a syscall.
#define LOG_DEBUG(format,...)
uint64_t thread_load_atomic_from_user(thread_t *thread, atomic_uint64_t *userObj, uint64_t *outValue)
Atomically load a 64-bit value from a user-space atomic variable.
uint64_t wait_block_commit(void)
Block the currently running thread.
uint64_t wait_block_setup(wait_queue_t **waitQueues, uint64_t amount, clock_t timeout)
Setup blocking but dont block yet.
void wait_block_cancel(void)
Cancel blocking.
uint64_t wait_unblock(wait_queue_t *waitQueue, uint64_t amount, errno_t err)
Unblock threads waiting on a wait queue.
void wait_queue_init(wait_queue_t *waitQueue)
Initialize wait queue.
void wait_queue_deinit(wait_queue_t *waitQueue)
Deinitialize wait queue.
thread_t * sched_thread(void)
Retrieves the currently running thread.
void futex_ctx_deinit(futex_ctx_t *ctx)
Deinitialize a per-process futex context. *.
void futex_ctx_init(futex_ctx_t *ctx)
Initialize a per-process futex context.
static void lock_init(lock_t *lock)
Initializes a lock.
#define LOCK_SCOPE(lock)
Acquires a lock for the reminder of the current scope.
clock_t timer_uptime(void)
Time since boot.
void map_deinit(map_t *map)
Deinitialize a map.
void map_entry_init(map_entry_t *entry)
Initialize a map entry.
static map_key_t map_key_uint64(uint64_t uint64)
Create a map key from a uint64_t.
uint64_t map_insert(map_t *map, const map_key_t *key, map_entry_t *value)
Insert a key-value pair into the map.
uint64_t map_init(map_t *map)
Initialize a map.
#define MAP_ENTRY_PTR_IS_VALID(entryPtr)
Check if a map entry pointer is valid (not NULL or tombstone).
map_entry_t * map_get(map_t *map, const map_key_t *key)
Get a value from the map by key.
#define EINVAL
Invalid argument.
#define errno
Error number variable.
futex_op_t
Futex operation enum.
uint64_t futex(atomic_uint64_t *addr, uint64_t val, futex_op_t op, clock_t timeout)
System call for fast user space mutual exclusion.
clock_t uptime(void)
System call for retreving the time since boot.
@ FUTEX_WAKE
The futex operation for waking up a amount of threads specified by the val argument.
@ FUTEX_WAIT
The futex operating for waiting until the value pointed to by addr is not equal to val.
#define NULL
Pointer error value.
#define ERR
Integer error value.
#define CONTAINER_OF(ptr, type, member)
Container of macro.
__UINT64_TYPE__ clock_t
A nanosecond time.
static futex_t * futex_ctx_get(futex_ctx_t *ctx, void *addr)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
Per-process futex context.
Virtual address space structure.
Thread of execution structure.
process_t * process
The parent process that the thread executes within.
tid_t id
The thread id, unique within a process_t.