Solaris 2.6: Speeding Up IPC with Doors
If you're still using message queues or pipes for high-frequency cross-process calls on Solaris, you're living in the past. Solaris 2.6 introduced Doors, a low-latency RPC mechanism that essentially allows a thread in one process to call a function in another process as if it were a local function call.
The kernel handles the context switch, but it's done much more efficiently than standard signal or socket-based IPC.
Setting up a Door Server
The server creates a "door" and associates it with a path in the filesystem.
#include <door.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void server_procedure(void *cookie, char *argp, size_t arg_size,
door_desc_t *dp, uint_t n_desc) {
char *response = "Door Call Received!";
door_return(response, strlen(response) + 1, NULL, 0);
}
int main() {
int dfd;
int ffd;
// Create the door
dfd = door_create(server_procedure, NULL, 0);
if (dfd == -1) {
perror("door_create");
exit(1);
}
// Attach it to a file
ffd = open("/tmp/my_door", O_RDWR|O_CREAT|O_TRUNC, 0666);
close(ffd);
fattach(dfd, "/tmp/my_door");
printf("Server is ready at /tmp/my_door\n");
sleep(1000000); // Wait for calls
return 0;
}
The Client Side
Calling the door is straightforward. You open the file and use door_call.
#include <door.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int dfd;
door_arg_t darg;
char *data = "Hello from Client";
dfd = open("/tmp/my_door", O_RDONLY);
if (dfd == -1) {
perror("open");
exit(1);
}
darg.data_ptr = data;
darg.data_size = strlen(data) + 1;
darg.desc_ptr = NULL;
darg.desc_num = 0;
darg.rbuf = NULL;
darg.rsize = 0;
if (door_call(dfd, &darg) == -1) {
perror("door_call");
exit(1);
}
printf("Response: %s\n", darg.data_ptr);
return 0;
}
This is significantly faster than using standard Unix domain sockets. The kernel literally hands off execution from the client thread to a pre-allocated server thread. If you're building high-performance systems on SPARC/Solaris, Doors are your best friend.
Aunimeda provides DevOps engineering and infrastructure services - CI/CD pipelines, containerization, cloud deployments, and monitoring setups.
Contact us to discuss your infrastructure needs. See also: DevOps Services, Custom Software Development