Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
threadx.h
Go to the documentation of this file.
1
27#ifndef NEXUS_OS_THREADX_H
28#define NEXUS_OS_THREADX_H
29#include "nexus/core/time.h"
30#include "nexus/os/wait.h"
31#include "tx_api.h"
32#ifdef __cplusplus
33extern "C" {
34#endif
35
37typedef struct {
38 TX_SEMAPHORE control;
39 uint32_t sequence;
40 uint32_t waiting;
41 bool live;
43
45typedef struct {
46 TX_THREAD control;
47 TX_SEMAPHORE finished;
48 void (*entry)(void*);
49 void* context;
50 uint32_t entered;
51 uint32_t returned;
52 bool live;
54
56typedef struct {
57 TX_THREAD control;
58 void (*entry)(void*);
59 void* context;
60 bool live;
62
64typedef struct {
65 TX_SEMAPHORE readable;
66 TX_SEMAPHORE writable;
67 uint8_t* storage;
68 size_t depth;
69 size_t item_size;
70 size_t head;
71 size_t tail;
72 size_t count;
73 uint32_t users;
74 bool live;
76
83
92
108nx_result_t nx_threadx_kernel_enter(void (*startup)(void*), void* context);
109
121
132
139
161
179 void* stack, size_t stack_bytes,
180 UINT priority, void (*entry)(void*),
181 void* context);
192 nx_time_us_t deadline);
213 const char* name, void* stack,
214 size_t stack_bytes, UINT priority,
215 void (*entry)(void*),
216 void* context);
217
228 size_t storage_bytes, size_t depth,
229 size_t item_size);
238 const void* item,
239 nx_time_us_t deadline);
248 void* item, nx_time_us_t deadline);
280 uint8_t* storage,
281 size_t storage_bytes, size_t depth,
282 size_t item_size,
283 size_t maximum_waiters);
301 const void* item, nx_time_us_t deadline,
314 void* item, nx_time_us_t deadline,
323#ifdef __cplusplus
324}
325#endif
326#endif /* NEXUS_OS_THREADX_H */
nx_result_t
Operation result; success at submission means admission only.
Definition status.h:21
Optional bounded close broadcast; registry is task-only.
Definition threadx.h:85
nx_threadx_queue_waiter_t * send_waiters
Definition threadx.h:87
nx_threadx_queue_t queue
Definition threadx.h:86
nx_threadx_queue_waiter_t * receive_waiters
Definition threadx.h:88
One binary latch; publishers quiesce before destruction.
Definition threadx.h:37
TX_SEMAPHORE control
Definition threadx.h:38
uint32_t waiting
Definition threadx.h:40
uint32_t sequence
Definition threadx.h:39
Permanent task has no completion latch, join or destroy.
Definition threadx.h:56
void(* entry)(void *)
Definition threadx.h:58
Exact arbitrary byte items; no native word-size narrowing.
Definition threadx.h:64
uint32_t users
Definition threadx.h:73
uint8_t * storage
Definition threadx.h:67
TX_SEMAPHORE readable
Definition threadx.h:65
TX_SEMAPHORE writable
Definition threadx.h:66
One explicit caller latch per simultaneous close-aware operation.
Definition threadx.h:78
nx_threadx_notify_t notification
Definition threadx.h:79
struct nx_threadx_queue_waiter * next
Definition threadx.h:80
Returning task retains all storage until external successful join.
Definition threadx.h:45
void(* entry)(void *)
Definition threadx.h:48
uint32_t entered
Definition threadx.h:50
TX_THREAD control
Definition threadx.h:46
uint32_t returned
Definition threadx.h:51
TX_SEMAPHORE finished
Definition threadx.h:47
Single-waiter notification port.
Definition wait.h:42
nx_result_t nx_threadx_permanent_task_start(nx_threadx_permanent_task_t *task, const char *name, void *stack, size_t stack_bytes, UINT priority, void(*entry)(void *), void *context)
Start a permanent task without a completion latch.
nx_result_t nx_threadx_notify_destroy(nx_threadx_notify_t *notification)
Destroy only after all publishers and waiter quiesce.
nx_result_t nx_threadx_task_discard_before_scheduler(nx_threadx_task_t *task)
Discard an unused task only inside actual bootstrap.
nx_result_t nx_threadx_queue_waiter_init(nx_threadx_queue_waiter_t *waiter)
Initialize one explicit close-aware operation latch.
nx_result_t nx_threadx_notify_init(nx_threadx_notify_t *notification)
Initialize one binary latch in task or actual bootstrap.
nx_result_t nx_threadx_task_start(nx_threadx_task_t *task, const char *name, void *stack, size_t stack_bytes, UINT priority, void(*entry)(void *), void *context)
Create a cooperatively returning task using exact storage.
nx_result_t nx_threadx_queue_waiter_destroy(nx_threadx_queue_waiter_t *waiter)
Destroy inactive waiter after its operation has returned.
nx_result_t nx_threadx_closable_queue_init(nx_threadx_closable_queue_t *queue, uint8_t *storage, size_t storage_bytes, size_t depth, size_t item_size, size_t maximum_waiters)
Add explicit bounded close broadcast to a byte queue.
bool nx_threadx_isr_allowed(void)
Read-only configurable-IRQ and selected mask-policy gate.
nx_result_t nx_threadx_closable_queue_close(nx_threadx_closable_queue_t *queue)
Reject sends, wake registered waiters, retain queued items.
nx_result_t nx_threadx_queue_send_until(nx_threadx_queue_t *queue, const void *item, nx_time_us_t deadline)
Task-only send; immediate readiness wins over expiration.
nx_result_t nx_threadx_external_tick_setup(uint32_t tick_hz)
Mandatory product hook only for explicit external Tick.
nx_result_t nx_threadx_closable_queue_receive_until(nx_threadx_closable_queue_t *queue, void *item, nx_time_us_t deadline, nx_threadx_queue_waiter_t *waiter)
Receive and drain previously queued items after close.
nx_result_t nx_threadx_closable_queue_send_until(nx_threadx_closable_queue_t *queue, const void *item, nx_time_us_t deadline, nx_threadx_queue_waiter_t *waiter)
Send with immediate close wake and explicit admission.
nx_result_t nx_threadx_closable_queue_destroy(nx_threadx_closable_queue_t *queue)
Destroy only a closed, drained and quiesced queue.
nx_wait_port_t nx_threadx_notify_port(nx_threadx_notify_t *notification)
Bind a sequence hint and one concurrent blocking waiter.
void nx_threadx_fail_stop(nx_result_t reason)
Product failure hook; default parks forever.
nx_result_t nx_threadx_queue_destroy(nx_threadx_queue_t *queue)
Destroy a drained queue after every caller quiesces.
struct nx_threadx_queue_waiter nx_threadx_queue_waiter_t
One explicit caller latch per simultaneous close-aware operation.
nx_result_t nx_threadx_queue_receive_until(nx_threadx_queue_t *queue, void *item, nx_time_us_t deadline)
Task-only receive; output changes only on SUCCESS.
nx_result_t nx_threadx_kernel_enter(void(*startup)(void *), void *context)
Explicit irreversible kernel entry owned by the product.
nx_result_t nx_threadx_queue_init(nx_threadx_queue_t *queue, uint8_t *storage, size_t storage_bytes, size_t depth, size_t item_size)
Initialize an exact arbitrary-byte bounded queue.
nx_result_t nx_threadx_task_join(nx_threadx_task_t *task, nx_time_us_t deadline)
Join a cooperatively returned task and prove detachment.
Absolute monotonic microsecond deadlines and wrap extension.
uint64_t nx_time_us_t
Microseconds in one boot/clock domain; no wall-clock semantics.
Definition time.h:20
Optional sequence-latched waiting without hidden workers.