From 701f8d0685105e055174eef38cac7cc044b1d29c Mon Sep 17 00:00:00 2001 From: jewelcodes Date: Fri, 6 Sep 2024 20:21:43 -0400 Subject: [PATCH] ipc: expose socket spinlock --- src/include/kernel/socket.h | 2 ++ src/ipc/sockinit.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/include/kernel/socket.h b/src/include/kernel/socket.h index 60d48308..62412d79 100644 --- a/src/include/kernel/socket.h +++ b/src/include/kernel/socket.h @@ -58,6 +58,8 @@ typedef struct SocketDescriptor { void socketInit(); SocketDescriptor *getLocalSocket(const struct sockaddr *, socklen_t); +void socketLock(); +void socketRelease(); /* socket system calls */ int socket(Thread *, int, int, int); diff --git a/src/ipc/sockinit.c b/src/ipc/sockinit.c index a88889f1..bb17f4e2 100644 --- a/src/ipc/sockinit.c +++ b/src/ipc/sockinit.c @@ -59,6 +59,24 @@ SocketDescriptor *getLocalSocket(const struct sockaddr *addr, socklen_t len) { return NULL; } +/* socketLock(): acquires the socket descriptor spinlock + * params: none + * returns: nothing + */ + +void socketLock() { + acquireLockBlocking(&lock); +} + +/* socketRelease(): frees the socket descriptor spinlock + * params: none + * returns: nothing + */ + +void socketRelease() { + releaseLock(&lock); +} + /* socket(): opens a communication socket * params: t - calling thread, NULL for kernel threads * params: domain - socket domain/family