scheduler: sched_setroot and sched_setcwd

This commit is contained in:
Matheus
2023-06-27 19:34:45 -03:00
parent 2b1140c161
commit 7e7504cde7
2 changed files with 24 additions and 0 deletions
+2
View File
@@ -81,6 +81,8 @@ int sched_sleep();
proc_t *sched_newproc();
vnode_t *sched_getcwd();
vnode_t *sched_getroot();
void sched_setcwd(vnode_t *);
void sched_setroot(vnode_t *);
thread_t *sched_newthread(void *ip, size_t kstacksize, int priority, proc_t *proc, void *ustack);
void sched_destroyproc(proc_t *);
void sched_destroythread(thread_t *);
+22
View File
@@ -297,6 +297,28 @@ vnode_t *sched_getroot() {
return getnodeslock(&proc->root);
}
static void setnodeslock(vnode_t **addr, vnode_t *new) {
proc_t *proc = _cpu()->thread->proc;
vnode_t *oldnode;
VOP_HOLD(new);
bool intstatus = interrupt_set(false);
spinlock_acquire(&proc->nodeslock);
oldnode = *addr;
*addr = new;
spinlock_release(&proc->nodeslock);
interrupt_set(intstatus);
VOP_RELEASE(oldnode);
}
void sched_setcwd(vnode_t *new) {
proc_t *proc = _cpu()->thread->proc;
setnodeslock(&proc->cwd, new);
}
void sched_setroot(vnode_t *new) {
proc_t *proc = _cpu()->thread->proc;
setnodeslock(&proc->root, new);
}
static void timerhook(context_t *context, dpcarg_t arg) {
thread_t* current = _cpu()->thread;