bit more consistent prepare for other primitives

This commit is contained in:
twoneis 2025-04-03 23:51:23 +02:00
parent e700ab4b60
commit 8d5a56f5f1
3 changed files with 23 additions and 9 deletions

View file

@ -1,3 +1,4 @@
#define _GNU_SOURCE
#include <sys/socket.h> #include <sys/socket.h>
#include <fcntl.h> #include <fcntl.h>
@ -6,6 +7,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "pipe_utils.h"
// where does this come from? // where does this come from?
#define OBJS_PER_SLAB 42 #define OBJS_PER_SLAB 42
@ -13,8 +16,6 @@
int pipes[PIPE_BUFFER][2]; int pipes[PIPE_BUFFER][2];
void alloc_pipes(int[2], int);
int int
main(void) main(void)
{ {
@ -23,16 +24,12 @@ main(void)
printf("main: fopen: %p\n", device); printf("main: fopen: %p\n", device);
printf("main: draining lower page free lists: %u objects\n",
PIPE_BUFFER);
for (size_t i = 0; i < PIPE_BUFFER; i++) { for (size_t i = 0; i < PIPE_BUFFER; i++) {
alloc_pipes(pipes[i], O_NONBLOCK); allocation_primitive(pipes[i], O_NONBLOCK);
} }
fclose(device); fclose(device);
printf("main: done\n"); printf("main: done\n");
} }
void
alloc_pipes(int fd[2], int flags)
{
pipe2(pipes, flags);
}

16
code/pipe_utils.c Normal file
View file

@ -0,0 +1,16 @@
#define _GNU_SOURCE
#include <sys/socket.h>
#include <fcntl.h>
#include <unistd.h>
#include "pipe_utils.h"
void
allocation_primitive(int fd[2])
{
pipe2(fd, O_NONBLOCK);
fcntl(fd[0], F_SETPIPE_SZ, 8192);
char buffer[0x100] = { 0 };
write(fd[1], buffer, 8);
}

1
code/pipe_utils.h Normal file
View file

@ -0,0 +1 @@
void allocation_primitive(int fd[2], int flags);