notify_create (nr 509)
Create a notification file descriptor for inter-process signaling.
Signature
notify_create(flags: u32) → fd or -errno
Arguments
| Arg | Register | Description |
|---|---|---|
| flags | rdi | Flags: NOTIFY_CLOEXEC (0x01) sets close-on-exec on the fd |
Return value
On success, returns a file descriptor for the notification object.
Errors
| Error | Condition |
|---|---|
| EINVAL | Unknown flags are set |
| EMFILE | Process fd table is full |
Description
Creates a notification fd for signaling between processes. The fd is used with two operations:
- Consumer: submits
OP_RING_WAIT(opcode 7) viaio_submiton the notification fd. The completion port blocks until the producer signals. - Producer: calls
notify(fd)(syscall 510) to signal. If anOP_RING_WAITis armed, a completion is posted to the consumer’s port.
The notification fd can be passed to child processes via inheritance
(clone + execve) or via IPC fd-passing (ipc_send / ipc_recv).
Semantics
- Edge-triggered, one-shot: one
notify()produces one completion. The consumer must re-submitOP_RING_WAITto receive the next signal. - Buffered: if
notify()is called beforeOP_RING_WAITis armed, the notification is buffered. The nextOP_RING_WAITcompletes immediately. Multiple pre-arm signals coalesce into one. - Single waiter: only one
OP_RING_WAITcan be pending per fd.
Flags
| Flag | Value | Description |
|---|---|---|
NOTIFY_CLOEXEC | 0x01 | Set close-on-exec on the returned fd |
Userspace usage (C)
#define SYS_NOTIFY_CREATE 509
#define NOTIFY_CLOEXEC 0x01
static long notify_create(unsigned int flags) {
return syscall(SYS_NOTIFY_CREATE, flags);
}
int nfd = notify_create(0);
Implementation
osl/src/notify.rs — sys_notify_create
Backing struct: libkernel/src/notify.rs — NotifyInner
See also
- notify (510) — signal the notification fd
- io_submit (502) —
OP_RING_WAITopcode - Completion Port Design — Phase 4