Standardization and API Ergonomics¶
The criterion. Native support for standard programming interfaces — a POSIX pthreads layer especially — so legacy C/C++ desktop or Linux thread code compiles onto an embedded target with minimal refactoring.
How Revera answers it¶
The threads / mutex / condition-variable surface is deliberately shaped so a pthreads engineer reads it
instantly and embedded-Linux thread code ports mechanically. Full POSIX compliance is a non-goal — the
kernel keeps its own safety model underneath: opaque kernel-owned handles (the property that makes
unprivileged threads safe), static pools, and caller-provided stacks (no heap). A thin, opt-in shim
compat/pthread.h presents the familiar pthread_* names over that; the
examples/pthread_api demo is a producer/consumer written in pure POSIX
pthreads that builds -Werror -pedantic-errors and runs on the kernel (verified on QEMU Cortex-A53:
produced=8 consumed=8 → PTHREAD-SHIM PASS).
What maps · how to use it¶
POSIX |
Revera |
Use these APIs |
|---|---|---|
|
attr create (pthread_create shape) |
|
|
near- |
|
|
1:1 (NORMAL / RECURSIVE / ERRORCHECK, PRIO_INHERIT) |
|
|
direct (timedwait is relative ms) |
|
Turn it on by including compat/pthread.h (opt-in) on an embedded board — not on
BOARD=host, which is real pthreads. Full signatures: API reference.
The deliberate divergences (kept as-is, documented)¶
Caller-provided static stacks —
pthread_createneeds a stack set viapthread_attr_setstack(a valid POSIX call), because the kernel allocates nothing. The malloc-free safety trade.Kernel-owned opaque handles —
pthread_tis atk_thread_t*, but the lifecycle is stricter (join reaps the pooled slot).No async cancellation / TLS /
PTHREAD_MUTEX_INITIALIZER—pthread_cancelis omitted by design; a pooled object cannot static-init, so ported code usespthread_mutex_init.Not on
BOARD=host— that arch is real pthreads; the shim is for embedded targets.
What can be claimed (honest)¶
A pthread-shaped compatibility subset — pthread_{create,join,detach,exit,self,equal} + sched_yield +
pthread_attr_* + pthread_mutex_*/mutexattr + pthread_cond_* — that ports embedded-Linux thread code
with two mechanical changes: switch the includes to the shim, and give each thread a static stack. It is
not a drop-in #include <pthread.h> and not POSIX-conformant (no cancellation, TLS, process scope, or
scheduling-policy attributes). Honest framing: “familiar pthread-style threads/mutex/cond API (opt-in shim),
targeting mechanical port-over — not full POSIX conformance.”
Learn more¶
Run it:
examples/pthread_api· the shimcompat/pthread.h.Full API: API reference.