You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Scheduler** — priority, round-robin, or hybrid.
15
15
-**Semaphores (binary + counting)** — blocking take, `try_take`, ISR-safe `give` with FIFO wake-up; counting mode via `hrt_sem_init_counting`.
16
+
-**Mutexes** — owner-tracked, non-recursive, FIFO waiter queue with direct handoff on unlock.
16
17
-**Message Queues** — fixed-size, copy-based FIFO, blocking/non-blocking and ISR support.
17
18
-**Static tasks** — stacks and TCBs supplied by the application.
18
19
-**CMake package** — install and consume via `find_package(HardRT)`.
@@ -21,7 +22,7 @@ Minimal footprint, predictable behavior, and zero hardware dependencies in its c
21
22
22
23
Please refer to [PORTING.md](docs/PORTING.md) for additional port inclusion.
23
24
24
-
> The POSIX port is for logic verification, not timing accuracy. ucontext is used and supported on Linux/glibc.
25
+
> The POSIX port is for logic verification, not timing accuracy. `ucontext` is used and supported on Linux/glibc.
25
26
26
27
> “On Cortex-M, the max time from tick to running the next highest priority ready task is bounded by: ISR tail + PendSV latency + context save/restore”
@@ -95,7 +96,7 @@ For further information and CMake flags, see the [Build](docs/BUILD.md) document
95
96
96
97
### Tick vs Timeslice
97
98
-**Tick:** base time unit generated by a timer interrupt (or POSIX signal). HardRT increments a counter each tick and wakes sleepers.
98
-
-**Timeslice:** number of ticks a task may run before being rotated under RR. In v0.3.0, rotation happens on yield/sleep; strict preemption at the slice end is planned.
99
+
-**Timeslice:** number of ticks a task may run before being rotated under RR. In the current implementation, rotation is triggered safely through the scheduler path rather than by direct context switching inside the tick hook.
99
100
100
101
101
102
### Policy: Round‑robin within one priority (Sequence at tick times)
const char* hrt_port_name(void); /* e.g. "posix" or "null" */
45
46
int hrt_port_id(void); /* 0=null, 1=posix, ... */
@@ -55,16 +56,16 @@ int hrt_create_task(hrt_task_fn fn, void* arg,
55
56
void hrt_start(void);
56
57
```
57
58
58
-
- `hrt_init` starts the port tick using `cfg->tick_hz` (defaults to 1000 Hz if 0). It also sets the scheduler policy and default timeslice.
59
-
- `hrt_create_task` registers a static task using the provided stack buffer. Minimum 64 words are required on hosted platforms (POSIX). If `attr==NULL`, the task inherits `cfg->default_slice` and default priority `HRT_PRIO1`.
60
-
- `hrt_start` enters the scheduler loop (does not return on POSIX; is a no-op on the null port).
59
+
- `hrt_init` initializes the kernel, applies scheduler configuration, and starts the port tick when the selected tick source requires it.
60
+
- `hrt_create_task` registers a static task using the provided stack buffer. Minimum stack constraints depend on the port.
61
+
- `hrt_start` enters the scheduler loop. On the null port it returns immediately.
61
62
62
63
### Control and time
63
64
64
65
```c
65
-
void hrt_sleep(uint32_t ms); /* sleep for ms; wakes on future ticks */
66
-
void hrt_yield(void); /* yield to allow others in same class */
67
-
uint32_t hrt_tick_now(void); /* system tick counter (increments at tick_hz; wraps on overflow) */
- Changing policy or default slice affects scheduling of READY tasks created after the change; existing tasks keep their configured `timeslice`.
78
+
- Changing policy affects scheduling decisions from the next scheduling point onward.
79
+
- Changing the default slice affects tasks created after the change. Existing tasks keep their configured timeslice.
78
80
79
81
### Round-robin semantics
80
82
81
-
- When policy is `HRT_SCHED_RR` or `HRT_SCHED_PRIORITY_RR` and a task has a non-zero `timeslice`, the running task’s quantum (`slice_left`) is decremented every tick.
82
-
- When the quantum reaches zero, a reschedule is pended from the tick ISR, and the actual rotation to the tail of the ready queue occurs when returning to the scheduler (safe context). This is how the POSIX and null ports integrate today.
83
-
- Tasks with `timeslice == 0` are cooperative within their priority class and will not be rotated by time slicing (but they can `hrt_yield()`).
83
+
- When policy is `HRT_SCHED_RR` or `HRT_SCHED_PRIORITY_RR` and a task has a non-zero `timeslice`, the running task’s quantum is decremented on tick accounting.
84
+
- When the quantum reaches zero, the scheduler reschedule path is pended and the actual rotation happens at a safe scheduling point.
85
+
- Tasks with `timeslice == 0` are cooperative within their priority class and will not be rotated by time slicing.
84
86
85
87
### Semaphores
86
88
87
-
The kernel provides a minimal semaphore primitive in `hardrt_sem.h` (binary by default, counting via an explicit init):
89
+
The kernel provides a minimal semaphore primitive in `hardrt_sem.h`.
0 commit comments