thread: remove struct proc abstraction
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
20905ec95f
commit
fa408751e1
16 changed files with 646 additions and 120 deletions
82
include/kernel/thread.h
Normal file
82
include/kernel/thread.h
Normal 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_ */
|
||||
Loading…
Reference in a new issue