#include <sys/abi.h>
#include <sys/mm/mempart.h>
-#include <hal/intc.h>
#include <sys/cpu.h>
#include <lunaix/fs/taskfs.h>
#include <lunaix/status.h>
#include <lunaix/syscall.h>
#include <lunaix/syslog.h>
-#include <lunaix/pcontext.h>
+#include <lunaix/hart_state.h>
#include <lunaix/kpreempt.h>
+#include <lunaix/generic/isrm.h>
+
#include <klibc/string.h>
+struct thread empty_thread_obj;
+
volatile struct proc_info* __current;
-volatile struct thread* current_thread;
+volatile struct thread* current_thread = &empty_thread_obj;
struct scheduler sched_ctx;
thread->process->state = PS_RUNNING;
thread->process->th_active = thread;
+ procvm_mount_self(vmspace(thread->process));
set_current_executing(thread);
switch_context();
continue;
}
- vmm_mount_pd(VMS_MOUNT_1, vmroot(pos->process));
- destory_thread(VMS_MOUNT_1, pos);
- vmm_unmount_pd(VMS_MOUNT_1);
+ struct proc_mm* mm = vmspace(pos->process);
+
+ procvm_mount(mm);
+ destory_thread(pos);
+ procvm_unmount(mm);
i++;
}
if (!(current_thread->state & ~PS_RUNNING)) {
current_thread->state = PS_READY;
__current->state = PS_READY;
+
}
+ procvm_unmount_self(vmspace(__current));
check_sleepers();
// round-robin scheduler
sched_ctx.procs_index = to_check->process->pid;
done:
- intc_notify_eos(0);
+ isrm_notify_eos(0);
run(to_check);
fail("unexpected return from scheduler");
proc->created = clock_systime();
proc->pgid = proc->pid;
- proc->sigreg = vzalloc(sizeof(struct sigregister));
+ proc->sigreg = vzalloc(sizeof(struct sigregistry));
proc->fdtable = vzalloc(sizeof(struct v_fdtable));
proc->mm = procvm_create(proc);
}
void
-destory_thread(ptr_t vm_mnt, struct thread* thread)
+destory_thread(struct thread* thread)
{
cake_ensure_valid(thread);
llist_delete(&thread->sleep.sleepers);
waitq_cancel_wait(&thread->waitqueue);
- thread_release_mem(thread, vm_mnt);
+ thread_release_mem(thread);
proc->thread_count--;
sched_ctx.ttable_len--;
delete_process(struct proc_info* proc)
{
pid_t pid = proc->pid;
+ struct proc_mm* mm = vmspace(proc);
assert(pid); // long live the pid0 !!
vfree(proc->fdtable);
- signal_free_registers(proc->sigreg);
+ signal_free_registry(proc->sigreg);
- vmm_mount_pd(VMS_MOUNT_1, vmroot(proc));
+ procvm_mount(mm);
struct thread *pos, *n;
llist_for_each(pos, n, &proc->threads, proc_sibs) {
// terminate and destory all thread unconditionally
- destory_thread(VMS_MOUNT_1, pos);
+ destory_thread(pos);
}
- procvm_cleanup(VMS_MOUNT_1, proc);
-
- vmm_unmount_pd(VMS_MOUNT_1);
+ procvm_unmount_release(mm);
cake_release(proc_pile, proc);
}