1. About

libapi is a wrapper library that uses the system call interface provided by the kernel to build a facade of C functions. These functions are the base of many libc components.

2. Tasking

2.1. g_atomic_lock

void g_atomic_lock(uint8_t* atom)
void g_atomic_lock_dual(uint8_t* atom_1, uint8_t* atom_2)

Used to perform thread-safe locking on a single byte. The given atom must point to valid memory in the current threads address space.

On execution, it is checked whether the byte at atom is 0. If it is 0, the byte is set to 1. If it is not 0, the executing thread blocks until the atom is set to 0.

The g_atomic_lock_dual version extends this functionality to work on two atoms. The function then blocks when both bytes are non-0. Once one of the atoms becomes 0, both atoms are set to 1.

2.2. g_create_thread

g_tid g_create_thread(void* function);
g_tid g_create_thread_d(void* function, void* userData);
g_tid g_create_thread_ds(void* function, void* userData, g_create_thread_status* out_status);

Creates a thread. The thread starts execution in the given function. The userData pointer is passed as an argument when supplied. When given, the out_status is set to the status of thread creation. This can be one of the codes below.

2.2.1. Constants of g_create_thread_status

Identifier Description

G_CREATE_THREAD_STATUS_SUCCESSFUL

Thread creation was successful

G_CREATE_THREAD_STATUS_FAILED

Thread creation failed, see log