wip: handle new task creation

This commit is contained in:
0x35c
2025-11-04 12:40:42 +01:00
parent 86ce44deff
commit 56cfe9f2be
3 changed files with 9 additions and 4 deletions

View File

@ -46,5 +46,6 @@ void kernel_main(multiboot_info_t *mbd, uint32_t magic)
create_kernel_task(); create_kernel_task();
signal(4, bozo); signal(4, bozo);
kill(0, 4); kill(0, 4);
create_task(42);
shell_init(); shell_init();
} }

View File

@ -13,7 +13,7 @@ struct frame_zone *head;
void switch_pd(uint32_t *pd, uint32_t *cr3) void switch_pd(uint32_t *pd, uint32_t *cr3)
{ {
current_pd = pd; // current_pd = pd;
asm volatile("mov %0, %%cr3" ::"r"(cr3)); asm volatile("mov %0, %%cr3" ::"r"(cr3));
} }

View File

@ -34,12 +34,14 @@ struct task *create_task(uint8_t uid)
return NULL; return NULL;
} }
new_task->heap[768] = ((uint32_t)boot_page_table1 - HEAP_END) | 0x03; new_task->heap[768] = ((uint32_t)boot_page_table1 - HEAP_END) | 0x03;
memcpy(new_task->heap, current_task->heap, 4096); // memcpy(new_task->heap, current_task->heap, 4096);
switch_pd(new_task->heap, new_task->cr3); current_pd = new_task->heap;
// switch_pd(new_task->heap, new_task->cr3);
// Allocate new stack on the newly allocated pd // Allocate new stack on the newly allocated pd
new_task->esp0 = alloc_pages(STACK_SIZE, NULL); new_task->esp0 = alloc_pages(STACK_SIZE, NULL);
switch_pd(current_task->heap, current_task->cr3); current_pd = kernel_pd;
// switch_pd(current_task->heap, current_task->cr3);
if (!new_task->esp0) { if (!new_task->esp0) {
vfree(new_task); vfree(new_task);
free_pages(new_task->heap, 4096); free_pages(new_task->heap, 4096);
@ -49,6 +51,8 @@ struct task *create_task(uint8_t uid)
new_task->next = current_task->next; new_task->next = current_task->next;
new_task->prev = current_task; new_task->prev = current_task;
current_task->next = new_task; current_task->next = new_task;
if (current_task->prev == current_task)
current_task->prev = new_task;
new_task->signals.pending = SIG_IGN; new_task->signals.pending = SIG_IGN;