API Reference

API Reference

Complete reference documentation for all LightOS APIs.


Core APIs

Thread API

FunctionDescription
thread::create()Create a new thread
thread::yield()Yield to other threads
thread::sleep()Sleep for duration
thread::sleep_until()Sleep until absolute time
thread::get_id()Get current thread ID
thread::set_priority()Change thread priority
thread::get_priority()Get current priority
thread::suspend()Suspend a thread
thread::resume()Resume a suspended thread

Scheduler API

FunctionDescription
scheduler::start()Start the scheduler
scheduler::lock()Disable context switching
scheduler::unlock()Re-enable context switching
scheduler::get_tick()Get current tick count

Synchronization APIs

Mutex API

FunctionDescription
mutex::lock()Acquire mutex (blocking)
mutex::try_lock()Try to acquire (non-blocking)
mutex::try_lock_for()Try with timeout
mutex::unlock()Release mutex

Semaphore API

FunctionDescription
semaphore::acquire()Decrement (blocking)
semaphore::try_acquire()Try to decrement
semaphore::try_acquire_for()Try with timeout
semaphore::release()Increment count
semaphore::count()Get current count

Queue API

FunctionDescription
queue::send()Send message (blocking)
queue::try_send()Try to send
queue::try_send_for()Try with timeout
queue::receive()Receive message (blocking)
queue::try_receive()Try to receive
queue::try_receive_for()Try with timeout
queue::size()Get queue size
queue::empty()Check if empty

Memory APIs

Pool Allocator

FunctionDescription
pool::allocate()Allocate from pool
pool::deallocate()Return to pool
pool::available()Get free count

Block Allocator

FunctionDescription
block_alloc::alloc()Allocate block
block_alloc::free()Free block

Timer APIs

FunctionDescription
timer::start_oneshot()Start one-shot timer
timer::start_periodic()Start periodic timer
timer::stop()Stop timer
timer::restart()Restart with same config
timer::is_active()Check if running

Hardware APIs

Interrupt Control

FunctionDescription
irq::enable()Enable interrupts
irq::disable()Disable interrupts
irq::register_handler()Register ISR
irq::set_priority()Set IRQ priority

Cache Control (ARM)

FunctionDescription
cache::enable_icache()Enable I-cache
cache::enable_dcache()Enable D-cache
cache::invalidate()Invalidate cache line
cache::clean()Clean cache line
cache::flush()Clean and invalidate

POSIX Compatibility Layer

pthread API

FunctionDescription
pthread_create()Create thread
pthread_join()Wait for thread
pthread_detach()Detach thread
pthread_exit()Exit thread
pthread_self()Get thread ID
pthread_setname_np()Set thread name
pthread_getname_np()Get thread name

pthread Mutex API

FunctionDescription
pthread_mutex_init()Initialize mutex
pthread_mutex_lock()Lock mutex
pthread_mutex_trylock()Try lock
pthread_mutex_unlock()Unlock mutex
pthread_mutex_destroy()Destroy mutex

Thread-Local Storage

FunctionDescription
pthread_key_create()Create TLS key
pthread_key_delete()Delete TLS key
pthread_setspecific()Set TLS value
pthread_getspecific()Get TLS value

Spinlock API

FunctionDescription
pthread_spin_init()Initialize spinlock
pthread_spin_lock()Lock spinlock
pthread_spin_trylock()Try lock
pthread_spin_unlock()Unlock spinlock
pthread_spin_destroy()Destroy spinlock

POSIX Timer API

FunctionDescription
timer_create()Create timer
timer_delete()Delete timer
timer_settime()Arm timer
timer_gettime()Get remaining time
timer_getoverrun()Get overrun count

Doxygen Documentation

For detailed API documentation with full parameter descriptions, see the Doxygen-generated documentation.