Skip to content

Add POSIX PSE51/PSE52 compatibility layer#184

Merged
jserv merged 1 commit intomasterfrom
posix
Feb 1, 2026
Merged

Add POSIX PSE51/PSE52 compatibility layer#184
jserv merged 1 commit intomasterfrom
posix

Conversation

@jserv
Copy link
Member

@jserv jserv commented Feb 1, 2026

This implementation provides support for the IEEE Std 1003.13-2003 POSIX real-time profiles on the F9 microkernel as an additional API layer for application development.

PSE51 (Minimal Realtime System Profile):

  • Threads: pthread_create/join/detach/exit/self/equal, cancellation
  • Mutexes: normal/recursive/errorcheck with timedlock support
  • Condition variables: wait/timedwait/signal/broadcast
  • Semaphores: init/wait/trywait/post/getvalue/destroy
  • Time: clock_gettime/nanosleep using L4_SystemClock
  • Signals: per-thread state with sigmask/sigaction/sigwait

PSE52 (Realtime Controller) partial:

  • Spinlocks: init/lock/trylock/unlock/destroy
  • Read-write locks and barriers (stubs)

Implementation highlights:

  • Notification-based blocking via L4_NotifyWait/Post/Clear
  • UTCB-keyed cancel_table for thread cancellation state
  • Thread lifecycle tracking (CREATED/RUNNING/EXITED)
  • Proper timeout handling with TIMEOUT_BIT clearing
  • Atomic sem_post overflow check to prevent TOCTOU race

Kernel changes:

  • Add SYS_NOTIFY_CLEAR syscall for IRQ-safe bit clearing
  • Fix race condition in sys_notify_post notification delivery

Close #98


Summary by cubic

Adds a POSIX API layer (PSE51 with partial PSE52) and kernel notification syscalls, enabling pthreads, semaphores, signals, and time on F9. Includes a POSIX test app with CI integration and fixes a notification delivery race.

  • New Features

    • POSIX PSE51: pthreads (create/join/detach/cancel), mutexes (normal/recursive/errorcheck + timedlock), condition variables, semaphores, signals, time (clock_gettime, nanosleep).
    • PSE52 partial: read-write locks and barriers.
    • New notification syscalls: SYS_NOTIFY_WAIT/POST/CLEAR with T_NOTIFY_BLOCKED state and proper wake semantics.
    • L4_SystemClock backed by atomic ktimer_get_now; improved IPC MR copying.
    • POSIX compliance app and unified test framework; CI runs “Kernel Test Suite” and “POSIX Compliance” in QEMU.
  • Migration

    • Replace legacy libposix headers with posix/* (pthread.h, semaphore.h, signal.h, time.h, sys/types.h).
    • Use L4_NotifyWait/L4_NotifyPost/L4_NotifyClear for notification-based blocking.
    • Enable CONFIG_USER_APP_POSIX to run the new test suite; user apps build now includes posix.

Written for commit 8283605. Summary will update on new commits.

cubic-dev-ai[bot]

This comment was marked as resolved.

This implementation provides support for the IEEE Std 1003.13-2003 POSIX
real-time profiles on the F9 microkernel as an additional API layer for
application development.

PSE51 (Minimal Realtime System Profile):
- Threads: pthread_create/join/detach/exit/self/equal, cancellation
- Mutexes: normal/recursive/errorcheck with timedlock support
- Condition variables: wait/timedwait/signal/broadcast
- Semaphores: init/wait/trywait/post/getvalue/destroy
- Time: clock_gettime/nanosleep using L4_SystemClock
- Signals: per-thread state with sigmask/sigaction/sigwait

PSE52 (Realtime Controller) partial:
- Spinlocks: init/lock/trylock/unlock/destroy
- Read-write locks and barriers (stubs)

Implementation highlights:
- Notification-based blocking via L4_NotifyWait/Post/Clear
- UTCB-keyed cancel_table for thread cancellation state
- Thread lifecycle tracking (CREATED/RUNNING/EXITED)
- Proper timeout handling with TIMEOUT_BIT clearing
- Atomic sem_post overflow check to prevent TOCTOU race

Kernel changes:
- Add SYS_NOTIFY_CLEAR syscall for IRQ-safe bit clearing
- Fix race condition in sys_notify_post notification delivery

Close #98
@jserv jserv merged commit 035a501 into master Feb 1, 2026
9 checks passed
@jserv jserv deleted the posix branch February 1, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement POSIX compatibile layer

1 participant