summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-02-21 19:41:51 +0100
committerAnton Kling <anton@kling.gg>2024-02-21 19:41:51 +0100
commit6c9cb0bd8ceb039ce387c850e25adc6f99cfcd6f (patch)
tree41ceaa1c30b1f93adf4469064eb5e5f3bb18661c /kernel
parent8ff63b062d724826d8017504063df9b92f8e6703 (diff)
Kerenel: Cleanup halt checking code
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile2
-rw-r--r--kernel/fs/tmpfs.c1
-rw-r--r--kernel/halts.c42
-rw-r--r--kernel/halts.h7
-rw-r--r--kernel/poll.c1
-rw-r--r--kernel/sched/scheduler.c42
-rw-r--r--kernel/sched/scheduler.h1
7 files changed, 43 insertions, 53 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 107dcd0..0cf45ec 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -1,6 +1,6 @@
CC="i686-sb-gcc"
AS="i686-sb-as"
-OBJ = arch/i386/boot.o init/kernel.o cpu/gdt.o cpu/reload_gdt.o cpu/idt.o cpu/io.o libc/stdio/print.o drivers/keyboard.o log.o drivers/pit.o libc/string/memcpy.o libc/string/strlen.o libc/string/memcmp.o drivers/ata.o libc/string/memset.o cpu/syscall.o read_eip.o libc/exit/assert.o process.o libc/string/strcpy.o arch/i386/mmu.o kmalloc.o fs/ext2.o fs/vfs.o fs/devfs.o cpu/spinlock.o random.o libc/string/strcmp.o crypto/ChaCha20/chacha20.o crypto/SHA1/sha1.o fs/tmpfs.o libc/string/isequal.o drivers/pst.o halts.o syscalls/ppoll.o syscalls/ftruncate.o kubsan.o syscalls/mmap.o drivers/serial.o syscalls/accept.o syscalls/bind.o syscalls/socket.o socket.o poll.o fs/fifo.o hashmap/hashmap.o fs/shm.o syscalls/shm.o elf.o ksbrk.o sched/scheduler.o syscalls/stat.o libc/string/copy.o libc/string/strncpy.o drivers/mouse.o libc/string/strlcpy.o libc/string/strcat.o drivers/vbe.o syscalls/msleep.o syscalls/uptime.o syscalls/mkdir.o drivers/pci.o drivers/rtl8139.o network/ethernet.o network/arp.o network/bytes.o network/ipv4.o network/udp.o syscalls/recvfrom.o math.o syscalls/sendto.o signal.o syscalls/kill.o syscalls/sigaction.o network/tcp.o drivers/ahci.o crypto/xoshiro256plusplus/xoshiro256plusplus.o syscalls/chdir.o syscalls/getcwd.o syscalls/isatty.o syscalls/randomfill.o syscalls/open.o syscalls/write.o syscalls/pwrite.o ipc.o syscalls/ipc.o syscalls/port.o syscalls/map_frames.o syscalls/virtual_to_physical.o syscalls/install_irq.o arch/i386/interrupts.o cpu/isr.o lib/stack.o lib/buffered_write.o lib/list.o
+OBJ = arch/i386/boot.o init/kernel.o cpu/gdt.o cpu/reload_gdt.o cpu/idt.o cpu/io.o libc/stdio/print.o drivers/keyboard.o log.o drivers/pit.o libc/string/memcpy.o libc/string/strlen.o libc/string/memcmp.o drivers/ata.o libc/string/memset.o cpu/syscall.o read_eip.o libc/exit/assert.o process.o libc/string/strcpy.o arch/i386/mmu.o kmalloc.o fs/ext2.o fs/vfs.o fs/devfs.o cpu/spinlock.o random.o libc/string/strcmp.o crypto/ChaCha20/chacha20.o crypto/SHA1/sha1.o fs/tmpfs.o libc/string/isequal.o drivers/pst.o syscalls/ppoll.o syscalls/ftruncate.o kubsan.o syscalls/mmap.o drivers/serial.o syscalls/accept.o syscalls/bind.o syscalls/socket.o socket.o poll.o fs/fifo.o hashmap/hashmap.o fs/shm.o syscalls/shm.o elf.o ksbrk.o sched/scheduler.o syscalls/stat.o libc/string/copy.o libc/string/strncpy.o drivers/mouse.o libc/string/strlcpy.o libc/string/strcat.o drivers/vbe.o syscalls/msleep.o syscalls/uptime.o syscalls/mkdir.o drivers/pci.o drivers/rtl8139.o network/ethernet.o network/arp.o network/bytes.o network/ipv4.o network/udp.o syscalls/recvfrom.o math.o syscalls/sendto.o signal.o syscalls/kill.o syscalls/sigaction.o network/tcp.o drivers/ahci.o crypto/xoshiro256plusplus/xoshiro256plusplus.o syscalls/chdir.o syscalls/getcwd.o syscalls/isatty.o syscalls/randomfill.o syscalls/open.o syscalls/write.o syscalls/pwrite.o ipc.o syscalls/ipc.o syscalls/port.o syscalls/map_frames.o syscalls/virtual_to_physical.o syscalls/install_irq.o arch/i386/interrupts.o cpu/isr.o lib/stack.o lib/buffered_write.o lib/list.o
CFLAGS = -Ofast -fsanitize=vla-bound,shift-exponent,pointer-overflow,shift,signed-integer-overflow,bounds -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL
#CFLAGS = -O0 -ggdb -ffreestanding -Wall -Werror -mgeneral-regs-only -Wimplicit-fallthrough -I./libc/include/ -I. -Wno-pointer-sign -DKERNEL
LDFLAGS=-flto -Ofast
diff --git a/kernel/fs/tmpfs.c b/kernel/fs/tmpfs.c
index 1054a27..bdb0dfb 100644
--- a/kernel/fs/tmpfs.c
+++ b/kernel/fs/tmpfs.c
@@ -2,7 +2,6 @@
#include <errno.h>
#include <fs/fifo.h>
#include <fs/tmpfs.h>
-#include <halts.h>
#include <sched/scheduler.h>
#include <typedefs.h>
diff --git a/kernel/halts.c b/kernel/halts.c
deleted file mode 100644
index c5afdac..0000000
--- a/kernel/halts.c
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <assert.h>
-#include <halts.h>
-#include <sched/scheduler.h>
-
-int isset_fdhalt(process_t *p) {
- int blocked = 0;
- struct list *read_list = &p->read_list;
- struct list *write_list = &p->write_list;
- struct list *disconnect_list = &p->disconnect_list;
-
- for (int i = 0;; i++) {
- vfs_inode_t *inode;
- if (!list_get(read_list, i, (void **)&inode)) {
- break;
- }
- if (inode->has_data) {
- return 0;
- }
- blocked = 1;
- }
- for (int i = 0;; i++) {
- vfs_inode_t *inode;
- if (!list_get(write_list, i, (void **)&inode)) {
- break;
- }
- if (inode->can_write) {
- return 0;
- }
- blocked = 1;
- }
- for (int i = 0;; i++) {
- vfs_inode_t *inode;
- if (!list_get(disconnect_list, i, (void **)&inode)) {
- break;
- }
- if (inode->is_open) {
- return 0;
- }
- blocked = 1;
- }
- return blocked;
-}
diff --git a/kernel/halts.h b/kernel/halts.h
deleted file mode 100644
index ed0637f..0000000
--- a/kernel/halts.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef HALTS_H
-#define HALTS_H
-#include <fs/vfs.h>
-#include <sched/scheduler.h>
-#include <typedefs.h>
-int isset_fdhalt(process_t *p);
-#endif
diff --git a/kernel/poll.c b/kernel/poll.c
index 963bfcc..276b592 100644
--- a/kernel/poll.c
+++ b/kernel/poll.c
@@ -1,5 +1,4 @@
#include <fs/vfs.h>
-#include <halts.h>
#include <interrupts.h>
#include <lib/list.h>
#include <poll.h>
diff --git a/kernel/sched/scheduler.c b/kernel/sched/scheduler.c
index 1aae1ce..614f621 100644
--- a/kernel/sched/scheduler.c
+++ b/kernel/sched/scheduler.c
@@ -324,6 +324,48 @@ int fork(void) {
return new_task->pid;
}
+int isset_fdhalt(process_t *p) {
+ if(NULL == p) {
+ p = get_current_task();
+ }
+ int blocked = 0;
+ struct list *read_list = &p->read_list;
+ struct list *write_list = &p->write_list;
+ struct list *disconnect_list = &p->disconnect_list;
+
+ for (int i = 0;; i++) {
+ vfs_inode_t *inode;
+ if (!list_get(read_list, i, (void **)&inode)) {
+ break;
+ }
+ if (inode->has_data) {
+ return 0;
+ }
+ blocked = 1;
+ }
+ for (int i = 0;; i++) {
+ vfs_inode_t *inode;
+ if (!list_get(write_list, i, (void **)&inode)) {
+ break;
+ }
+ if (inode->can_write) {
+ return 0;
+ }
+ blocked = 1;
+ }
+ for (int i = 0;; i++) {
+ vfs_inode_t *inode;
+ if (!list_get(disconnect_list, i, (void **)&inode)) {
+ break;
+ }
+ if (inode->is_open) {
+ return 0;
+ }
+ blocked = 1;
+ }
+ return blocked;
+}
+
int is_halted(process_t *process) {
for (int i = 0; i < 2; i++) {
if (process->halts[i]) {
diff --git a/kernel/sched/scheduler.h b/kernel/sched/scheduler.h
index 596bedb..ff38034 100644
--- a/kernel/sched/scheduler.h
+++ b/kernel/sched/scheduler.h
@@ -3,7 +3,6 @@ typedef struct Process process_t;
#define SCHEDULER_H
#include <fs/ext2.h>
#include <fs/vfs.h>
-#include <halts.h>
#include <ipc.h>
#include <lib/list.h>
#include <lib/stack.h>