diff --git a/include/task.h b/include/task.h index 561ccb4..0a51790 100644 --- a/include/task.h +++ b/include/task.h @@ -63,7 +63,6 @@ typedef struct Process struct Process* next; // Следующий процесс file_t* file_descriptors[MAX_OPEN_FILES]; - uint8_t zombie; } Process; extern Process* current; diff --git a/src/tasking/switch.asm b/src/tasking/switch.asm index ec16bd6..01186e5 100644 --- a/src/tasking/switch.asm +++ b/src/tasking/switch.asm @@ -1,14 +1,3 @@ -struc PCB - .PID resd 1 ; Offset: 0 - .STATE resd 1 ; Offset: 4 - .KSTACK resd 1 ; Offset: 8 - .CONTEXT resd 1 ; Offset: 12 - .TF resd 1 ; Offset: 16 - .FLAGS resd 1 ; Offset: 20 - .NEXT resd 1 ; Offset: 24 - .PAGE_DIRECTORY resd 1 ; Offset: 28 -endstruc - ; void switchProcess(Process* next) section .text global switchProcess diff --git a/src/tasking/syscalls.c b/src/tasking/syscalls.c index 053bb83..e01996a 100644 --- a/src/tasking/syscalls.c +++ b/src/tasking/syscalls.c @@ -49,11 +49,10 @@ const char* flags_to_mode_str(int flags) { int sys_exit(TrapFrame *tf) { int error_code = tf->ebx; - printf("killing task\n"); + debug_log("killing task\n"); task_kill(current); asm("sti"); while(1){} - printf("wtf??"); return error_code; } diff --git a/src/tasking/task.c b/src/tasking/task.c index 196820a..4d16317 100644 --- a/src/tasking/task.c +++ b/src/tasking/task.c @@ -8,21 +8,15 @@ Process* current = 0; Process* queue = 0; -Process* zombie_list = 0; uint32_t irq_disable_counter = 0; uint32_t pid_counter; uint32_t task_count; #define KSTACKSIZE 4096 -#define USTACKSIZE 4096 extern void trapret(void); extern void switchProcess(Process* next); -//extern Process* queue; - -extern uint32_t pid_counter; -extern uint32_t task_count; Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t* pagedir) { @@ -58,19 +52,11 @@ Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t* p->tf->eflags = FL_IF; p->tf->eip = (uint32_t)func; - p->pagedir = pagedir;//(uint32_t*)create_page_dir(); + p->pagedir = pagedir; if(ring == 3) { - /*void* user_stack_physical = alloc_page(); - - uint32_t user_stack_virtual_top = 0xBFFFF000 - ((p->pid -1) * (USTACKSIZE + 4096)); // Уникальный верх стека для каждого процесса - uint32_t user_stack_virtual_base = user_stack_virtual_top - USTACKSIZE; - - map_page_in_directory(p->pagedir, user_stack_physical, (void*)user_stack_virtual_base, PAGE_PRESENT | PAGE_RW | PAGE_USER); // Флаги 0x7 - */ - - p->tf->usermode_esp = user_esp;//user_stack_virtual_top; + p->tf->usermode_esp = user_esp; } @@ -92,7 +78,6 @@ Process* task_create(uint32_t func, uint32_t user_esp, uint32_t ring, uint32_t* curr = curr->next; curr->next = p; } - task_count++; return p; } @@ -164,8 +149,6 @@ void task2() while (1) { a++; printf("task2 %X\n", a); } } -void jump_usermode2(void) ; - void scheduler_init() { uint32_t* kernel_tasks_pagedir = (uint32_t*)create_page_dir(); @@ -174,7 +157,7 @@ void scheduler_init() } void task_kill(Process* proc) { - //that proc != current is sus + //TODO: that proc != current is sus if (!proc || proc != current) return; scheduler_lock();