mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
scheduler: sched_setroot and sched_setcwd
This commit is contained in:
@@ -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 *);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user