Rename event pipes to broadcast pipes

This commit is contained in:
2025-09-09 17:52:19 +02:00
parent ab224eda8e
commit 1029db6342
6 changed files with 16 additions and 15 deletions

View File

@ -101,7 +101,7 @@ Proc *proc_spawnkern(void (*ent)(void), char *name) {
proc->platformdata.cr3 = hal_vmm_current_cr3(); proc->platformdata.cr3 = hal_vmm_current_cr3();
proc->state = PROC_READY; proc->state = PROC_READY;
proc->pid = pids++; proc->pid = pids++;
spinlock_init(&proc->eventpipes_spinlock); spinlock_init(&proc->bcast_pipes.spinlock);
return proc; return proc;
} }
@ -167,7 +167,7 @@ Proc *proc_spawnuser(char *mountpoint, char *path) {
proc->platformdata.trapframe.rip = aux.entry; proc->platformdata.trapframe.rip = aux.entry;
proc->state = PROC_READY; proc->state = PROC_READY;
proc->pid = pids++; proc->pid = pids++;
spinlock_init(&proc->eventpipes_spinlock); spinlock_init(&proc->bcast_pipes.spinlock);
return proc; return proc;
} }

View File

@ -45,10 +45,11 @@ typedef struct Proc {
VfsObj *vobjs[PROC_VFSHANDLES_MAX]; VfsObj *vobjs[PROC_VFSHANDLES_MAX];
uint64_t vobjcnt; uint64_t vobjcnt;
IpcPipe *pipes[PROC_PIPEHANDLES_MAX]; IpcPipe *pipes[PROC_PIPEHANDLES_MAX];
IpcPipe *eventpipes; struct {
SpinLock eventpipes_spinlock; IpcPipe *list;
SpinLock spinlock;
} bcast_pipes;
} Proc; } Proc;
typedef struct { typedef struct {

View File

@ -13,7 +13,7 @@ Ps2KbFastBuf PS2KB_BUF;
void ps2kbproc_init(Proc *proc) { void ps2kbproc_init(Proc *proc) {
PS2KBPROC = proc; PS2KBPROC = proc;
PS2KBPROC->eventpipes = NULL; PS2KBPROC->bcast_pipes.list = NULL;
PS2KB_BUF.rbuf.buffer = dlmalloc(IPC_PIPE_MAX); PS2KB_BUF.rbuf.buffer = dlmalloc(IPC_PIPE_MAX);
PS2KB_BUF.rbuf.cap = IPC_PIPE_MAX; PS2KB_BUF.rbuf.cap = IPC_PIPE_MAX;
@ -33,13 +33,13 @@ void ps2kbproc_fn(void) {
} }
spinlock_release(&PS2KB_BUF.spinlock); spinlock_release(&PS2KB_BUF.spinlock);
if (i > 0) { if (i > 0) {
spinlock_acquire(&PS2KBPROC->eventpipes_spinlock); spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock);
IpcPipe *head = PS2KBPROC->eventpipes; IpcPipe *head = PS2KBPROC->bcast_pipes.list;
while (head != NULL) { while (head != NULL) {
ipc_pipewrite(head, (uint8_t *)&kbchr, sizeof(kbchr)); ipc_pipewrite(head, (uint8_t *)&kbchr, sizeof(kbchr));
head = head->next; head = head->next;
} }
spinlock_release(&PS2KBPROC->eventpipes_spinlock); spinlock_release(&PS2KBPROC->bcast_pipes.spinlock);
} }
} }
} }

View File

@ -94,7 +94,7 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
ret = ipc_piperead(pipe, buffer, len1); ret = ipc_piperead(pipe, buffer, len1);
} break; } break;
case IPCPIPE_REG_EVT_PIPE: { case IPCPIPE_ADD_BCAST: {
if (pipenum >= PROC_PIPEHANDLES_MAX) { if (pipenum >= PROC_PIPEHANDLES_MAX) {
ret = E_NOMEMORY; ret = E_NOMEMORY;
goto done; goto done;
@ -119,9 +119,9 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
goto done; goto done;
} }
spinlock_acquire(&proc2->eventpipes_spinlock); spinlock_acquire(&proc2->bcast_pipes.spinlock);
LL_APPEND(proc2->eventpipes, pipe); LL_APPEND(proc2->bcast_pipes.list, pipe);
spinlock_release(&proc2->eventpipes_spinlock); spinlock_release(&proc2->bcast_pipes.spinlock);
ret = E_OK; ret = E_OK;
} break; } break;

View File

@ -13,7 +13,7 @@ enum {
IPCPIPE_MAKE = 0, IPCPIPE_MAKE = 0,
IPCPIPE_READ = 1, IPCPIPE_READ = 1,
IPCPIPE_WRITE = 2, IPCPIPE_WRITE = 2,
IPCPIPE_REG_EVT_PIPE = 3, IPCPIPE_ADD_BCAST = 3,
}; };
#endif // SHARE_SYSDEFS_IPCPIPE_H_ #endif // SHARE_SYSDEFS_IPCPIPE_H_

View File

@ -31,7 +31,7 @@ void main(void) {
uprintf("failed to create 10th pipe\n"); uprintf("failed to create 10th pipe\n");
} }
int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_REG_EVT_PIPE, NULL, 1); int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_ADD_BCAST, NULL, 1);
uprintf("%d\n", r); uprintf("%d\n", r);
while(1) { while(1) {