Note on patch structure: This consolidated diff is provided solely for an initial architectural overview and demonstration. Once the overall design and approach are agreed upon, I plan to split this work into a clean series of small, atomic patches (separating kernel infrastructure, syscalls, userland library, tests, and removing the demo code) for formal code review and commit.
Add Doors IPC to FreeBSD. This change brings the Solaris/illumos Doors model to FreeBSD and extends it to support event-driven applications, bulk data transfers, and continuous streams. Compatibility is centered on the traditional Doors programming model; the FreeBSD-specific extensions are described separately below.
The implementation has three main components:
- DoorFS implements door endpoints in the kernel, including call and reply, descriptor transfer, revocation, and endpoint lifetime. A dedicated system call interface exposes Door operations to userspace. DoorFS also provides /dev/doorctl for registering and discovering named endpoints without requiring a filesystem attachment for each service.
- NameFS provides fattach() and fdetach() so applications can publish a door at a filesystem path, as in the traditional Doors model. Named discovery through /dev/doorctl is an additional option.
- libdoor provides the userspace API for both traditional Doors operations and the FreeBSD-specific extensions.
The synchronous door_call() path uses a scheduler shuttle to hand execution from the caller to the server thread. The caller is suspended while waiting for the reply. This is useful for synchronous RPC, but it means a thread that also drives an event loop cannot dispatch unrelated work while the call is outstanding. The extended protocol addresses that constraint and two related data-transfer needs:
Extension - Motivation and behavior
One-way calls - Submit work without waiting for a server reply. This fits notifications and commands that do not need a response. Successful submission does not mean the server has completed the work.
Asynchronous calls - Separate submission from completion so a language runtime or application event loop can continue dispatching work while a request is outstanding. The caller can still collect the result later.
Door SHM - Avoid repeatedly copying large payloads through the call and reply path. The Door SHM protocol governs which participants can access a region and within what bounds, so the application can exchange bulk data through a bounded shared region.
Door SHM Pair - Support continuous exchange over shared memory, where using a separate RPC for every item gives up much of the benefit of a shared buffer. Pair provides notifications in both directions so participants can publish or consume batches with fewer wakeups. A plain SHM-plus-futex design leaves applications to assemble the mapping, peer lifetime, and wakeup conventions themselves. Pair ties those pieces to the Door SHM protocol. The application still owns its message layout, queue discipline, and backpressure.
Repositories
- FreeBSD source tree - doors_ipc branch: complete FreeBSD source tree with the kernel and libdoor changes. https://github.com/eduardsiboshvili/freebsd-src/tree/doors_ipc
- Monograph and design documentation: architecture, API semantics, invariants, and benchmark methodology. https://github.com/eduardsiboshvili/freebsd-door-docs
- Standalone examples: sample clients and servers for the API. https://github.com/eduardsiboshvili/freebsd-doors-examples
- Demo applications: Door Stack, including the nginx integration, PGDoor/PostgreSQL, and benchmark applications. https://github.com/eduardsiboshvili/freebsd-doors-demo-apps