API Reference
API Reference
Complete reference documentation for all LightOS APIs.
Core APIs
Thread API
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
pool::allocate() | Allocate from pool |
pool::deallocate() | Return to pool |
pool::available() | Get free count |
Block Allocator
| Function | Description |
|---|
block_alloc::alloc() | Allocate block |
block_alloc::free() | Free block |
Timer APIs
| Function | Description |
|---|
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
| Function | Description |
|---|
irq::enable() | Enable interrupts |
irq::disable() | Disable interrupts |
irq::register_handler() | Register ISR |
irq::set_priority() | Set IRQ priority |
Cache Control (ARM)
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
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
| Function | Description |
|---|
pthread_key_create() | Create TLS key |
pthread_key_delete() | Delete TLS key |
pthread_setspecific() | Set TLS value |
pthread_getspecific() | Get TLS value |
Spinlock API
| Function | Description |
|---|
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
| Function | Description |
|---|
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.