AKOS  v1.0.0
Documentation
Loading...
Searching...
No Matches
thread.c File Reference

Thread management, scheduling, and thread messaging integration. More...

#include "thread.h"
#include "core.h"
#include "list.h"
#include "memory.h"
#include "timer.h"
#include "priority.h"
#include "port.h"
#include <string.h>
Include dependency graph for thread.c:

Go to the source code of this file.

Classes

struct  task_tcb_t

Macros

#define TASK_IDLE_PRI   (OS_CFG_PRIO_MAX - 1u)
#define TASK_TIMER_PRI   ((uint8_t)OS_CFG_TIMER_TASK_PRI)
#define TASK_TIMER_STK_SIZE   (100u)
#define SIZE_OF_TCB   (sizeof(task_tcb_t))

Functions

const thread_t __start_task_desc[] __attribute__ ((weak))
uint32_t akos_thread_get_tick (void)
 Get current tick counter.
uint8_t akos_thread_get_app_thread_count (void)
 Get number of application threads defined via AKOS_THREAD_DEFINE.
uint8_t akos_thread_get_idle_thread_id (void)
 Get the runtime thread ID assigned to the idle thread.
uint8_t akos_thread_get_timer_thread_id (void)
 Get the runtime thread ID assigned to the timer thread.
void akos_thread_register_static_threads (void)
 Create all statically defined application tasks plus system tasks.
uint8_t akos_thread_increment_tick (void)
 Tick hook: unblock delayed tasks and select next runnable task.
void akos_thread_delay (const uint32_t tick_to_delay)
 Delay current thread for a number of ticks.
void akos_thread_start (void)
 Start scheduler state variables.
void akos_thread_post_msg_dynamic (uint8_t des_thread_id, int32_t sig, void *p_content, uint8_t msg_size)
 Post dynamic payload message to another thread.
void akos_thread_post_msg_pure (uint8_t des_thread_id, int32_t sig)
 Post pure signal message to another thread.
msg_t * akos_thread_wait_for_msg (uint32_t time_out)
 Wait for a message on current thread queue.

Variables

task_tcb_t *volatile tcb_curr_ptr = NULL
task_tcb_t *volatile tcb_high_rdy_ptr = NULL

Detailed Description

Thread management, scheduling, and thread messaging integration.

Author
Snoopy3921 - AK Foundation
Date
2026/05/08

Definition in file thread.c.

Macro Definition Documentation

◆ SIZE_OF_TCB

#define SIZE_OF_TCB   (sizeof(task_tcb_t))

Definition at line 31 of file thread.c.

◆ TASK_IDLE_PRI

#define TASK_IDLE_PRI   (OS_CFG_PRIO_MAX - 1u)

Definition at line 22 of file thread.c.

◆ TASK_TIMER_PRI

#define TASK_TIMER_PRI   ((uint8_t)OS_CFG_TIMER_TASK_PRI)

Definition at line 24 of file thread.c.

◆ TASK_TIMER_STK_SIZE

#define TASK_TIMER_STK_SIZE   (100u)

Definition at line 26 of file thread.c.

Function Documentation

◆ akos_thread_delay()

void akos_thread_delay ( const uint32_t tick_to_delay)

Delay current thread for a number of ticks.

Delay current thread by specified ticks.

Parameters
tick_to_delayDelay in ticks.

Definition at line 541 of file thread.c.

◆ akos_thread_get_app_thread_count()

uint8_t akos_thread_get_app_thread_count ( void )

Get number of application threads defined via AKOS_THREAD_DEFINE.

Returns
Number of app threads linked into the image. App IDs are 0..count-1.

Definition at line 69 of file thread.c.

◆ akos_thread_get_idle_thread_id()

uint8_t akos_thread_get_idle_thread_id ( void )

Get the runtime thread ID assigned to the idle thread.

Returns
Idle thread ID.

Definition at line 74 of file thread.c.

◆ akos_thread_get_tick()

uint32_t akos_thread_get_tick ( void )

Get current tick counter.

Get current system tick.

Returns
Current tick value.

Definition at line 64 of file thread.c.

◆ akos_thread_get_timer_thread_id()

uint8_t akos_thread_get_timer_thread_id ( void )

Get the runtime thread ID assigned to the timer thread.

Returns
Timer thread ID.

Definition at line 79 of file thread.c.

◆ akos_thread_increment_tick()

uint8_t akos_thread_increment_tick ( void )

Tick hook: unblock delayed tasks and select next runnable task.

Tick handler routine called from SysTick.

Returns
OS_TRUE if context switch is needed, otherwise OS_FALSE.

Definition at line 471 of file thread.c.

◆ akos_thread_post_msg_dynamic()

void akos_thread_post_msg_dynamic ( uint8_t des_thread_id,
int32_t sig,
void * p_content,
uint8_t msg_size )

Post dynamic payload message to another thread.

Post dynamic message to destination thread.

Parameters
des_thread_idDestination thread ID.
sigMessage signal.
p_contentPayload pointer.
msg_sizePayload size in bytes.

Definition at line 571 of file thread.c.

◆ akos_thread_post_msg_pure()

void akos_thread_post_msg_pure ( uint8_t des_thread_id,
int32_t sig )

Post pure signal message to another thread.

Post pure signal message to destination thread.

Parameters
des_thread_idDestination thread ID.
sigMessage signal.

Definition at line 654 of file thread.c.

◆ akos_thread_register_static_threads()

void akos_thread_register_static_threads ( void )

Create all statically defined application tasks plus system tasks.

Create all statically defined threads and kernel internal threads.

Definition at line 402 of file thread.c.

◆ akos_thread_start()

void akos_thread_start ( void )

Start scheduler state variables.

Start scheduler state.

Definition at line 555 of file thread.c.

◆ akos_thread_wait_for_msg()

msg_t * akos_thread_wait_for_msg ( uint32_t time_out)

Wait for a message on current thread queue.

Wait for message from current thread queue.

Parameters
time_outTimeout in ticks. Use OS_CFG_DELAY_MAX for infinite wait.
Returns
Message pointer, or NULL on timeout.

Definition at line 735 of file thread.c.

Variable Documentation

◆ tcb_curr_ptr

task_tcb_t* volatile tcb_curr_ptr = NULL

Definition at line 34 of file thread.c.

◆ tcb_high_rdy_ptr

task_tcb_t* volatile tcb_high_rdy_ptr = NULL

Definition at line 35 of file thread.c.