entry: silent save process context on entry

This commit is contained in:
Michael Shaw 2024-08-21 02:26:52 -04:00
commit f29b9395d1
3 changed files with 98 additions and 51 deletions

View file

@ -59,7 +59,6 @@ ssize_t sys_read(int fd, void *buf, size_t count)
if (tmp_buf == NULL)
return -ENOMEM;
ssize_t ret = vfs_read(file, tmp_buf, fdesc->pos, count);
proc->state = PROC_RUNNING;
@ -153,17 +152,35 @@ void sys_exit(int status)
pid_t sys_fork()
{
struct proc *proc = proc_find(getpid());
if (proc == NULL)
return -1;
struct proc *parent = proc_find(getpid());
struct proc *proc = proc_create();
struct proc *new_proc = proc_fork(proc);
if (new_proc == NULL)
return -1;
proc_clone_mmap(parent, proc);
sys_set_return(new_proc, 0);
/* copy file descriptors */
struct rbnode *node = rbt_minimum(parent->fd_map.root);
while (node) {
struct file_descriptor *fdesc = (void *)node->value;
struct file *file = fdesc->file;
return new_proc->pid;
struct file_descriptor *new_fdesc = slab_alloc(fd_slab);
new_fdesc->fd = fdesc->fd;
new_fdesc->file = file;
new_fdesc->pos = fdesc->pos;
new_fdesc->flags = fdesc->flags;
struct rbnode *new_node = rbt_insert(&proc->fd_map, fdesc->fd);
new_node->value = (uintptr_t)new_fdesc;
node = rbt_successor(node);
}
/* copy parent */
proc->parent = parent;
proc->regs = parent->regs;
sys_set_return(proc, 0);
return proc->pid;
}
static void syscall_insert(uint64_t syscall_no, syscall_t syscall)