PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
wait.h File Reference
#include <kernel/cpu/regs.h>
#include <kernel/sync/lock.h>
#include <errno.h>
#include <sys/list.h>
#include <sys/proc.h>
Include dependency graph for wait.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  wait_entry_t
 Represents a thread waiting on a wait queue. More...
 
struct  wait_queue_t
 The primitive that threads block on. More...
 
struct  wait_client_t
 Represents a thread in the waiting subsystem. More...
 
struct  wait_t
 Represents one instance of the waiting subsystem for a CPU. More...
 

Macros

#define WAIT_ALL   UINT64_MAX
 Used to indicate that the wait should unblock all waiting threads.
 
#define WAIT_BLOCK(queue, condition)
 Blocks until the condition is true, will test the condition on every wakeup.
 
#define WAIT_BLOCK_TIMEOUT(queue, condition, timeout)
 Blocks until the condition is true, condition will be tested on every wakeup. Reaching the timeout will always unblock.
 
#define WAIT_BLOCK_LOCK(queue, lock, condition)
 Blocks until the condition is true, condition will be tested on every wakeup. Will release the lock before blocking and acquire it again after waking up.
 
#define WAIT_BLOCK_LOCK_TIMEOUT(queue, lock, condition, timeout)
 Blocks until the condition is true, condition will be tested on every wakeup. Will release the lock before blocking and acquire it again after waking up. Reaching the timeout will always unblock.
 
#define WAIT_QUEUE_CREATE(name)   {.lock = LOCK_CREATE(), .entries = LIST_CREATE(name.entries)}
 Create a wait queue initializer.
 

Typedefs

typedef struct thread thread_t
 
typedef struct cpu cpu_t
 
typedef struct wait_entry wait_entry_t
 
typedef struct wait_queue wait_queue_t
 
typedef struct wait_client wait_client_t
 
typedef struct wait wait_t
 

Functions

void wait_queue_init (wait_queue_t *queue)
 Initialize wait queue.
 
void wait_queue_deinit (wait_queue_t *queue)
 Deinitialize wait queue.
 
void wait_client_init (wait_client_t *client)
 Initialize a threads wait client.
 
void wait_init (wait_t *wait)
 Initialize an instance of the waiting subsystem.
 
void wait_check_timeouts (interrupt_frame_t *frame, cpu_t *self)
 Check for timeouts and unblock threads as needed.
 
uint64_t wait_block_prepare (wait_queue_t **waitQueues, uint64_t amount, clock_t timeout)
 Prepare to block the currently running thread.
 
void wait_block_cancel (void)
 Cancels blocking of the currently running thread.
 
uint64_t wait_block_commit (void)
 Block the currently running thread.
 
bool wait_block_finalize (interrupt_frame_t *frame, cpu_t *self, thread_t *thread, clock_t uptime)
 Finalize blocking of a thread.
 
void wait_unblock_thread (thread_t *thread, errno_t err)
 Unblock a specific thread.
 
uint64_t wait_unblock (wait_queue_t *queue, uint64_t amount, errno_t err)
 Unblock threads waiting on a wait queue.
 

Typedef Documentation

◆ thread_t

typedef struct thread thread_t

Definition at line 10 of file wait.h.

◆ cpu_t

typedef struct cpu cpu_t

Definition at line 11 of file wait.h.

◆ wait_entry_t

typedef struct wait_entry wait_entry_t

Definition at line 13 of file wait.h.

◆ wait_queue_t

typedef struct wait_queue wait_queue_t

Definition at line 14 of file wait.h.

◆ wait_client_t

typedef struct wait_client wait_client_t

Definition at line 15 of file wait.h.

◆ wait_t

typedef struct wait wait_t

Definition at line 16 of file wait.h.