Task switching fix? but doesnt exit process gracefully
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@ iso_root
|
|||||||
*.gch
|
*.gch
|
||||||
*/*.gch
|
*/*.gch
|
||||||
*/*/*.gch
|
*/*/*.gch
|
||||||
|
.gdb_history
|
||||||
4
Makefile
4
Makefile
@@ -36,6 +36,10 @@ debug:
|
|||||||
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
|
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
|
||||||
gdb pepperk --command=debug.gdb
|
gdb pepperk --command=debug.gdb
|
||||||
|
|
||||||
|
debug2:
|
||||||
|
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
|
||||||
|
pwndbg pepperk --command=debug.gdb
|
||||||
|
|
||||||
run: build-iso
|
run: build-iso
|
||||||
/usr/bin/qemu-system-x86_64 -cdrom pepper.iso -serial stdio
|
/usr/bin/qemu-system-x86_64 -cdrom pepper.iso -serial stdio
|
||||||
|
|
||||||
|
|||||||
@@ -197,17 +197,17 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
|
|||||||
|
|
||||||
case 32: // Timer Interrupt
|
case 32: // Timer Interrupt
|
||||||
ticks++;
|
ticks++;
|
||||||
|
// Send an EOI so that we can continue having interrupts
|
||||||
|
outb(0x20, 0x20);
|
||||||
|
|
||||||
if (ticks % SCHEDULER_QUANTUM == 0)
|
if (ticks % SCHEDULER_QUANTUM == 0)
|
||||||
{
|
{
|
||||||
CLEAR_INTERRUPTS;
|
return scheduler_schedule(context);
|
||||||
struct cpu_status_t* current_ctx = scheduler_schedule(context);
|
//struct cpu_status_t* current_ctx = scheduler_schedule(context);
|
||||||
process_switch(current_ctx->iret_rsp, current_ctx->iret_rip);
|
//process_switch(current_ctx->iret_rsp, current_ctx->iret_rip);
|
||||||
SET_INTERRUPTS;
|
//SET_INTERRUPTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send an EOI so that we can continue having interrupts
|
|
||||||
outb(0x20, 0x20);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 33:
|
case 33:
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void hcf()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Doing nothing (can be interrupted)
|
// Doing nothing (can be interrupted)
|
||||||
void idle() {for(;;)asm("hlt");}
|
void idle() {SET_INTERRUPTS; for(;;)asm("hlt");}
|
||||||
|
|
||||||
uint8_t kernel_stack[KERNEL_STACK_SIZE] __attribute__((aligned(16)));
|
uint8_t kernel_stack[KERNEL_STACK_SIZE] __attribute__((aligned(16)));
|
||||||
|
|
||||||
@@ -110,12 +110,16 @@ void kmain()
|
|||||||
|
|
||||||
vmm_init();
|
vmm_init();
|
||||||
|
|
||||||
|
struct process_t* idle_proc = process_create("idle", (void*)idle_main, 0);
|
||||||
struct process_t* pedicel = process_create("pedicel", (void*)pedicel_main, 0);
|
struct process_t* pedicel = process_create("pedicel", (void*)pedicel_main, 0);
|
||||||
|
|
||||||
process_display_list(processes_list);
|
process_display_list(processes_list);
|
||||||
|
|
||||||
scheduler_init();
|
scheduler_init();
|
||||||
|
|
||||||
|
current_process = idle_proc;
|
||||||
|
current_process->status = RUNNING;
|
||||||
|
|
||||||
SET_INTERRUPTS;
|
SET_INTERRUPTS;
|
||||||
|
|
||||||
keyboard_init(FR);
|
keyboard_init(FR);
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ void process_switch(uint64_t stack_addr, uint64_t code_addr)
|
|||||||
// Just mark as DEAD then idle. Scheduler will delete process at next timer interrupt % quantum.
|
// Just mark as DEAD then idle. Scheduler will delete process at next timer interrupt % quantum.
|
||||||
void process_exit()
|
void process_exit()
|
||||||
{
|
{
|
||||||
|
DEBUG("Exiting from process '%s'", current_process->name);
|
||||||
CLEAR_INTERRUPTS;
|
CLEAR_INTERRUPTS;
|
||||||
if (current_process)
|
if (current_process)
|
||||||
{
|
{
|
||||||
@@ -167,6 +168,7 @@ void process_exit()
|
|||||||
}
|
}
|
||||||
SET_INTERRUPTS;
|
SET_INTERRUPTS;
|
||||||
|
|
||||||
|
outb(0x20, 0x20);
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
asm("hlt");
|
asm("hlt");
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "mem/paging/paging.h"
|
#include "mem/paging/paging.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "io/serial/serial.h"
|
||||||
|
|
||||||
extern struct process_t* processes_list;
|
extern struct process_t* processes_list;
|
||||||
extern struct process_t* current_process;
|
extern struct process_t* current_process;
|
||||||
@@ -20,7 +21,7 @@ void scheduler_init()
|
|||||||
|
|
||||||
struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
|
struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
|
||||||
{
|
{
|
||||||
//current_process->context = context;
|
current_process->context = context;
|
||||||
current_process->status = READY;
|
current_process->status = READY;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -49,7 +50,6 @@ struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
|
|||||||
|
|
||||||
load_cr3(VIRT_TO_PHYS((uint64_t)current_process->root_page_table));
|
load_cr3(VIRT_TO_PHYS((uint64_t)current_process->root_page_table));
|
||||||
DEBUG("loaded process pml4 into cr3");
|
DEBUG("loaded process pml4 into cr3");
|
||||||
/* process_switch(current_process->context->rbp, current_process->context->iret_rip);
|
|
||||||
DEBUG("switched to process rip!"); */
|
|
||||||
return current_process->context;
|
return current_process->context;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user