Skip to content

Land PSE51 realtime signals#8

Merged
jserv merged 1 commit into
mainfrom
pse51
May 12, 2026
Merged

Land PSE51 realtime signals#8
jserv merged 1 commit into
mainfrom
pse51

Conversation

@jserv
Copy link
Copy Markdown
Contributor

@jserv jserv commented May 12, 2026

Wire the wait-for-signal API set and bounded sigqueue payload path that _POSIX_REALTIME_SIGNALS expects, on top of the existing kill/sigaction core. SYS_SIGSUSPEND, SYS_SIGTIMEDWAIT, and SYS_SIGQUEUE round out the PSE51 signal surface; SYS_SIGQUEUE is appended at slot 100 so the rest of the syscall numbering stays stable across the branch.

Process-directed pending state splits into two distinct sources so that plain kill() and queued sigqueue() can coexist on the same signo without silently swallowing each other:

  • proc_pending_plain tracks kill-style instances (one bit per signo).
  • queued[signo] is a bounded FIFO of sigqueue payloads.
  • proc_pending is the OR summary refreshed under sig_lock so the lockless return-to-user fast path stays coherent.

signal_claim_proc_pending_locked consumes exactly one source per call (queue first, then plain), so consuming a queued payload never clears a sibling plain instance.

The per-signo ring is sized SIGQUEUE_MAX_PER_SIGNO + 1. Producers cap at SIGQUEUE_MAX_PER_SIGNO (EAGAIN behavior unchanged for user space); the extra slot is reserved for the rollback path. If sys_sigtimedwait dequeues a payload and copy_to_user later faults, the new signal_restore_proc_pending_locked helper re-inserts the payload at the queue head and always succeeds for a single in-flight consumer. The multi-consumer race past the reserved slot drops the payload but keeps the signal observable via the plain bit, as defense-in-depth.


Summary by cubic

Adds PSE51 realtime signals with wait-for-signal APIs and bounded sigqueue payloads. Introduces SYS_SIGQUEUE, wires SYS_SIGSUSPEND, and extends SYS_SIGTIMEDWAIT to optionally return a queued value.

  • New Features

    • Split process-directed pending into proc_pending_plain (bitmask) and per-signo FIFO queued[], with proc_pending as the OR summary for the fast path.
    • Bounded queue per signal (SIGQUEUE_MAX_PER_SIGNO = 4) with an internal +1 slot to guarantee lossless rollback after copy_to_user faults; overflow during multi-consumer rollback drops the payload but sets the plain bit to keep the signal observable.
    • signal_claim_proc_pending_locked consumes exactly one source (queue first, then plain) so kill() and sigqueue() on the same signal coexist; SYS_SIGTIMEDWAIT returns the signo and, when present, writes the queued value to the optional payload-out pointer; handlers still receive only the signo.
  • Migration

    • New syscall: SYS_SIGQUEUE is added at slot 100; all existing syscall numbers remain unchanged.
    • _POSIX_REALTIME_SIGNALS stays 1; payloads are exposed via a Mazu-specific ABI (not full siginfo_t/SA_SIGINFO).
    • No changes required for existing handlers; use SYS_SIGTIMEDWAIT (with payload-out) and SYS_SIGQUEUE to send/receive values.

Written for commit 7b872a8. Summary will update on new commits.

Wire the wait-for-signal API set and bounded sigqueue payload path that
_POSIX_REALTIME_SIGNALS expects, on top of the existing kill/sigaction
core. SYS_SIGSUSPEND, SYS_SIGTIMEDWAIT, and SYS_SIGQUEUE round out the
PSE51 signal surface; SYS_SIGQUEUE is appended at slot 100 so the rest
of the syscall numbering stays stable across the branch.

Process-directed pending state splits into two distinct sources so that
plain kill() and queued sigqueue() can coexist on the same signo without
silently swallowing each other:
  - proc_pending_plain tracks kill-style instances (one bit per signo).
  - queued[signo] is a bounded FIFO of sigqueue payloads.
  - proc_pending is the OR summary refreshed under sig_lock so the
    lockless return-to-user fast path stays coherent.

signal_claim_proc_pending_locked consumes exactly one source per call
(queue first, then plain), so consuming a queued payload never clears a
sibling plain instance.

The per-signo ring is sized SIGQUEUE_MAX_PER_SIGNO + 1. Producers cap
at SIGQUEUE_MAX_PER_SIGNO (EAGAIN behavior unchanged for user space);
the extra slot is reserved for the rollback path. If sys_sigtimedwait
dequeues a payload and copy_to_user later faults, the new
signal_restore_proc_pending_locked helper re-inserts the payload at the
queue head and always succeeds for a single in-flight consumer. The
multi-consumer race past the reserved slot drops the payload but keeps
the signal observable via the plain bit, as defense-in-depth.
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 10 files

@jserv jserv merged commit 2e9333e into main May 12, 2026
7 checks passed
@jserv jserv deleted the pse51 branch May 12, 2026 17:15
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.

1 participant