thread: remove struct proc abstraction

struct proc was a redundant abstraction. everything can be tracked by
just threads

Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
Michael Shaw 2026-08-12 21:24:38 -04:00
commit e41877b268
Signed by: michaelsshaw
GPG key ID: 5A5E0FB20708A9E7
16 changed files with 646 additions and 120 deletions

82
include/kernel/thread.h Normal file
View file

@ -0,0 +1,82 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _THREAD_H_
#define _THREAD_H_
#include <kernel/types.h>
#include <kernel/spinlock.h>
#include <kernel/mem.h>
#include <kernel/page.h>
#include <fs/vfs.h>
#include <lib/rbtree.h>
struct ehdr;
struct phdr;
#define THREAD_STATE_RUNNING 0
#define THREAD_STATE_WAITING 1
#define THREAD_STATE_DNS 2
#define THREAD_STATE_BLOCKED 3
#define THREAD_STATE_ZOMBIE 4
typedef u64 tid_t;
struct vm_area {
vaddr_t start;
size_t len;
u64 flags;
};
struct file {
dirent_t *dirent;
u64 flags;
u64 offset;
u64 refcount;
spinlock_t lock;
};
struct thread {
tid_t tid;
uaddr_t kstack_ptr;
uaddr_t kstack_top;
uaddr_t ustack_top;
size_t stack_size;
u64 state;
u64 tls_base;
struct thread *next;
tid_t group;
pgd_t *pgd;
spinlock_t mem_lock;
rbtree_t memmap;
spinlock_t alloc_lock;
rbtree_t alloc_map;
uaddr_t entry;
spinlock_t fd_lock;
size_t fd_array_size;
struct file *fdt;
struct ehdr *ehdr;
struct phdr *phdrs;
size_t n_phdrs;
char *name;
};
void thread_mmap(struct thread *thread, paddr_t p, vaddr_t v, size_t len, u64 flags);
ssize_t thread_load_file(const char *file, struct thread *thread);
struct thread *thread_create(void);
struct thread *thread_fork(struct thread *parent);
void thread_free(struct thread *thread);
void thread_init();
tid_t alloc_tid();
void schedule();
#endif /* _THREAD_H_ */