diff options
Diffstat (limited to 'src/kernel/task')
-rw-r--r-- | src/kernel/task/idt.c | 3 | ||||
-rw-r--r-- | src/kernel/task/syscall.c | 11 | ||||
-rw-r--r-- | src/kernel/task/task.c | 18 | ||||
-rw-r--r-- | src/kernel/task/task.h | 6 |
4 files changed, 28 insertions, 10 deletions
diff --git a/src/kernel/task/idt.c b/src/kernel/task/idt.c index cff4ae9..0f3c2f2 100644 --- a/src/kernel/task/idt.c +++ b/src/kernel/task/idt.c @@ -198,7 +198,6 @@ void idt_handleIrq(int number, int_callback func) { void idt_waitIrq(int number) { if (number < 16 && number >= 0 && proc_priv() <= PL_DRIVER) { irq_wakeup[number] = current_thread; - current_thread->state = TS_WAKEWAIT; - tasking_schedule(); + thread_goInactive(); } } diff --git a/src/kernel/task/syscall.c b/src/kernel/task/syscall.c index 752864c..51c46f1 100644 --- a/src/kernel/task/syscall.c +++ b/src/kernel/task/syscall.c @@ -8,6 +8,7 @@ r->eax = name(r->ebx, r->ecx); } #define CALL0V(name, scname) static void scname(struct registers* r) { name(); } #define CALL1V(name, scname) static void scname(struct registers* r) { name(r->ebx); } +#define CALL2V(name, scname) static void scname(struct registers* r) { name(r->ebx, r->ecx); } CALL0V(thread_exit, thread_exit_sc); CALL0V(tasking_switch, schedule_sc); @@ -15,17 +16,23 @@ CALL1V(thread_sleep, thread_sleep_sc); CALL1V(process_exit, process_exit_sc); CALL1(monitor_write, printk_sc); CALL1V(idt_waitIrq, irq_wait_sc); +CALL0(proc_priv, proc_priv_sc); +CALL2(shm_create, shm_create_sc); +CALL1(shm_delete, shm_delete_sc); static void thread_new_sc(struct registers* r) { thread_new(current_thread->process, (thread_entry)r->ebx, (void*)r->ecx); } int_callback syscalls[] = { - thread_exit_sc, + thread_exit_sc, //0 schedule_sc, thread_sleep_sc, process_exit_sc, printk_sc, - thread_new_sc, + thread_new_sc, //5 irq_wait_sc, + proc_priv_sc, + shm_create_sc, + shm_delete_sc, 0 }; diff --git a/src/kernel/task/task.c b/src/kernel/task/task.c index 622eaa1..6959676 100644 --- a/src/kernel/task/task.c +++ b/src/kernel/task/task.c @@ -88,10 +88,6 @@ void tasking_switch() { : : "r"(current_thread->ebp), "r"(current_thread->esp), "r"(current_thread->eip)); } -void tasking_schedule() { - asm volatile("int $64" : : "a"(1)); -} - void tasking_updateKernelPagetable(uint32_t idx, struct page_table *table, uint32_t tablephysical) { if (idx < 896) return; struct process* it = processes; @@ -119,13 +115,19 @@ uint32_t tasking_handleException(struct registers *regs) { thread_exit_stackJmp(EX_TH_EXCEPTION); } PANIC("This should never have happened. Please report this."); + return 0; } void thread_sleep(uint32_t msecs) { if (current_thread == 0) return; current_thread->state = TS_SLEEPING; current_thread->timeWait = timer_time() + msecs; - tasking_schedule(); + tasking_switch(); +} + +void thread_goInactive() { + current_thread->state = TS_WAKEWAIT; + tasking_switch(); } int proc_priv() { @@ -271,6 +273,11 @@ struct process *process_new(struct process* parent, uint32_t uid, uint32_t privi p->pagedir = pagedir_new(); p->next = processes; p->stacksBottom = 0xDF000000; + + p->next_objdesc = 0; + p->objects = 0; + obj_createP(p); //create process' root object and add descriptor 0 to it + processes = p; return p; } @@ -296,6 +303,7 @@ static void process_delete(struct process *pr) { while (it->next->process == pr) thread_delete(it->next); it = it->next; } + obj_closeall(pr); pagedir_delete(pr->pagedir); if (processes == pr) { processes = pr->next; diff --git a/src/kernel/task/task.h b/src/kernel/task/task.h index dd5461e..b2a5434 100644 --- a/src/kernel/task/task.h +++ b/src/kernel/task/task.h @@ -3,6 +3,7 @@ #include <types.h> #include <mem/paging.h> +#include <ipc/object.h> #include "idt.h" #define TS_RUNNING 0 @@ -29,6 +30,9 @@ struct process { struct page_directory *pagedir; size_t stacksBottom; + struct obj_descriptor *objects; + uint32_t next_objdesc; + struct process *next; //Forms a linked list }; @@ -48,11 +52,11 @@ extern struct thread *current_thread; void tasking_init(); void tasking_switch(); -void tasking_schedule(); void tasking_updateKernelPagetable(uint32_t idx, struct page_table *table, uint32_t tablePhysical); uint32_t tasking_handleException(struct registers *regs); void thread_sleep(uint32_t msecs); +void thread_goInactive(); //Blocks the current thread. another one must be there to wake it up at some point. int proc_priv(); //Returns current privilege level void thread_exit(); void process_exit(uint32_t retval); |