AKOS  v1.0.0
Documentation
Loading...
Searching...
No Matches
thread.h
Go to the documentation of this file.
1/****************************************************************************/
12
13#ifndef THREAD_H
14#define THREAD_H
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20
21#include <stdint.h>
22#include <stddef.h>
23#include "config.h"
24
25#include "message.h"
26
27#define AKOS_THREAD_DEFINE(_name, _id, _entry, _arg, _prio, _queue_size, _stack_size) \
28 const thread_t _name __attribute__((used, section("task_desc"))) = { \
29 .id = (thread_id_t)(_id), \
30 .pf_thread = (thread_func_t)(_entry), \
31 .p_arg = (void *)(_arg), \
32 .prio = (uint8_t)(_prio), \
33 .queue_size = (size_t)(_queue_size), \
34 .stack_size = (size_t)(_stack_size), \
35 }
36
50
51 typedef struct thread_tcb *thread_handle_t;
52 typedef struct thread thread_t;
53
59 typedef void (*thread_func_t)(void *p_arg);
60
65 typedef uint8_t thread_id_t;
66
71 struct thread
72 {
75 void *p_arg;
76 uint8_t prio;
77 size_t queue_size;
78 size_t stack_size;
79 };
80
85 uint32_t akos_thread_get_tick(void);
86
91
97
102 uint8_t akos_thread_get_idle_thread_id(void);
103
109
114 uint8_t akos_thread_increment_tick(void);
115
120 void akos_thread_delay(const uint32_t tick_to_delay);
121
125 void akos_thread_start(void);
126
134 void akos_thread_post_msg_dynamic(uint8_t des_thread_id, int32_t sig, void *p_content, uint8_t msg_size);
135
141 void akos_thread_post_msg_pure(uint8_t des_thread_id, int32_t sig);
142
148 msg_t *akos_thread_wait_for_msg(uint32_t time_out);
149
150#ifdef __cplusplus
151}
152#endif
153#endif /* THREAD_H */
Build-time configuration macros for AK-mOS.
Message object and message queue APIs.
Static thread descriptor used during thread table registration.
Definition thread.h:72
size_t queue_size
Definition thread.h:77
size_t stack_size
Definition thread.h:78
thread_id_t id
Definition thread.h:73
thread_func_t pf_thread
Definition thread.h:74
void * p_arg
Definition thread.h:75
uint8_t prio
Definition thread.h:76
msg_t * akos_thread_wait_for_msg(uint32_t time_out)
Wait for message from current thread queue.
Definition thread.c:735
uint8_t akos_thread_get_timer_thread_id(void)
Get the runtime thread ID assigned to the timer thread.
Definition thread.c:79
void akos_thread_register_static_threads(void)
Create all statically defined threads and kernel internal threads.
Definition thread.c:402
uint32_t akos_thread_get_tick(void)
Get current system tick.
Definition thread.c:64
void akos_thread_start(void)
Start scheduler state.
Definition thread.c:555
uint8_t akos_thread_increment_tick(void)
Tick handler routine called from SysTick.
Definition thread.c:471
uint8_t akos_thread_get_app_thread_count(void)
Get number of application threads defined via AKOS_THREAD_DEFINE.
Definition thread.c:69
void(* thread_func_t)(void *p_arg)
Thread entry function signature.
Definition thread.h:59
void akos_thread_delay(const uint32_t tick_to_delay)
Delay current thread by specified ticks.
Definition thread.c:541
void akos_thread_post_msg_dynamic(uint8_t des_thread_id, int32_t sig, void *p_content, uint8_t msg_size)
Post dynamic message to destination thread.
Definition thread.c:571
thread_state_t
Runtime state of a thread control block.
Definition thread.h:42
@ THREAD_STATE_READY
Definition thread.h:44
@ THREAD_STATE_DELAYED
Definition thread.h:45
@ THREAD_STATE_RUNNING
Definition thread.h:43
@ THREAD_STATE_DELAYED_ON_MSG
Definition thread.h:48
@ THREAD_STATE_SUSPENDED
Definition thread.h:46
@ THREAD_STATE_SUSPENDED_ON_MSG
Definition thread.h:47
uint8_t akos_thread_get_idle_thread_id(void)
Get the runtime thread ID assigned to the idle thread.
Definition thread.c:74
uint8_t thread_id_t
Numeric thread identifier type.
Definition thread.h:65
void akos_thread_post_msg_pure(uint8_t des_thread_id, int32_t sig)
Post pure signal message to destination thread.
Definition thread.c:654
struct thread_tcb * thread_handle_t
Definition thread.h:51