11#ifndef __MUTEKI_THREADING_H__
12#define __MUTEKI_THREADING_H__
67 unsigned char waiting_by[8];
Common include file for all muteki-shims headers.
#define SYS_ALIGN(n)
Attribute for forcing alignment.
Definition common.h:86
Besta error code constants and functions.
unsigned int kerrno_t
Definition errno.h:22
bool OSPostMsgQue(message_queue_t *queue, const message_queue_message_t *message)
Push a message into the queue.
thread_wait_reason_e
Thread wait reason enum.
Definition threading.h:24
@ WAIT_ON_QUEUE
Definition threading.h:32
@ WAIT_ON_SUSPEND
Definition threading.h:34
@ WAIT_ON_SEMAPHORE
Definition threading.h:28
@ WAIT_ON_NONE
Definition threading.h:26
@ WAIT_ON_CRITICAL_SECTION
Definition threading.h:36
@ WAIT_ON_EVENT
Definition threading.h:30
@ WAIT_ON_SLEEP
Definition threading.h:38
int(* thread_func_t)(void *user_data)
Thread function type.
Definition threading.h:56
wait_result_t OSWaitForEvent(event_t *event, short timeout)
Wait for an event.
enum wait_result_e wait_result_t
Result of waitables.
int OSTerminateThread(thread_t *thr, int exit_code)
Terminate a thread.
wait_result_t OSWaitForSemaphore(semaphore_t *semaphore, short timeout)
Wait and acquire a semaphore.
bool OSSuspendThread(thread_t *thr)
Suspend a thread from outside of that thread.
bool OSPeekMsgQue(message_queue_t *queue, message_queue_message_t *message)
Peek the bottom of the queue without popping the message.
void OSLeaveCriticalSection(critical_section_t *cs)
Leave/release a critical section.
bool OSReleaseSemaphore(semaphore_t *semaphore)
Release a semaphore.
semaphore_t * OSCreateSemaphore(short init_ctr)
Create an semaphore descriptor.
thread_t * OSCreateThread(thread_func_t func, void *user_data, size_t stack_size, bool defer_start)
Create a new thread.
bool OSCloseSemaphore(semaphore_t *semaphore)
Destroy a semaphore.
bool OSResetEvent(event_t *event)
Reset the event flag.
char message_queue_message_t[16]
Message type for message queues.
Definition threading.h:75
bool OSCloseMsgQue(message_queue_t *queue)
Destroy a message queue descriptor.
wait_result_e
Result of waitables.
Definition threading.h:44
@ WAIT_RESULT_TIMEOUT
Definition threading.h:46
@ WAIT_RESULT_ERROR
Definition threading.h:50
@ WAIT_RESULT_RESOLVED
Definition threading.h:48
event_t * OSCreateEvent(short latch_on, int flag)
Create an event descriptor.
bool OSSendMsgQue(message_queue_t *queue, const message_queue_message_t *message)
Push a message into the queue and reschedule immediately.
void OSSleep(short millis)
Sleep for millis milliseconds.
short OSGetCurrentlyRunningTCBPrio(void)
Get the current running thread's priority (slot number).
void OSEnterCriticalSection(critical_section_t *cs)
Enter/aquire a critical section.
void OSInitCriticalSection(critical_section_t *cs)
Initialize a critical section descriptor.
short OSGetThreadPriority(thread_t *thr)
Get the thread priority (slot number).
void OSDeleteCriticalSection(critical_section_t *cs)
Destroy a critical section descriptor.
message_queue_t * OSCreateMsgQue(unsigned short size)
Create a message queue descriptor.
bool OSWakeUpThread(thread_t *thr)
Force wake up a sleeping thread.
bool OSCloseEvent(event_t *event)
Destroy the event descriptor.
bool OSSetThreadPriority(thread_t *thr, short new_slot)
Set the thread priority (slot number).
bool OSGetMsgQue(message_queue_t *queue, message_queue_message_t *message)
Pop a message from the queue.
bool OSResumeThread(thread_t *thr)
Start/restart a previously suspended thread.
int OSExitThread(int exit_code)
Terminate current thread.
bool OSSetEvent(event_t *event)
Set the event flag.
Critical section descriptor structure.
Definition threading.h:203
threading_waitable_t wait_state
Wait state of the current critical section.
Definition threading.h:214
int magic
Definition threading.h:205
thread_t * thr
Definition threading.h:207
unsigned short refcount
Definition threading.h:209
Event descriptor structure.
Definition threading.h:185
int flag
Definition threading.h:189
threading_waitable_t wait_state
Wait state of the current event.
Definition threading.h:196
int magic
Definition threading.h:187
short latch_on
Definition threading.h:191
Nonatomic backend storage for message queues.
Definition threading.h:81
short push_idx
Definition threading.h:89
message_queue_message_t * messages
Definition threading.h:83
short pop_idx
Definition threading.h:87
unsigned short size
Definition threading.h:85
Message queue descriptor structure.
Definition threading.h:221
threading_waitable_t wait_state
Wait state of the current event.
Definition threading.h:231
message_queue_nonatomic_t * storage
Definition threading.h:225
int magic
Definition threading.h:223
Semaphore descriptor structure.
Definition threading.h:168
short ctr
Definition threading.h:173
threading_waitable_t wait_state
Wait state of the current semaphore.
Definition threading.h:178
int magic
Definition threading.h:170
Thread descriptor structure.
Definition threading.h:117
kerrno_t kerrno
Definition threading.h:127
void * stack
Definition threading.h:123
short wait_reason
Definition threading.h:140
unsigned char slot_high3b_bit
Definition threading.h:150
short slot
Definition threading.h:142
uintptr_t ktls[8]
Definition threading.h:161
int magic
Definition threading.h:119
short unk_0x1c
Definition threading.h:133
thread_func_t thread_func
Definition threading.h:131
thread_t * next
Definition threading.h:156
unsigned char slot_low3b_bit
Definition threading.h:148
short sleep_counter
Definition threading.h:135
char slot_low3b
Definition threading.h:144
event_t * event
Definition threading.h:152
thread_t * prev
Definition threading.h:154
char slot_high3b
Definition threading.h:146
int exit_code
Definition threading.h:125
uintptr_t * sp
Definition threading.h:121
char unk_0x34[0x20]
Definition threading.h:159
uintptr_t unk_0x14
Definition threading.h:129
Common data structure for waitables.
Definition threading.h:63
unsigned char active_bytes
Definition threading.h:65