process_mem #10

Merged
xamidev merged 5 commits from process_mem into main 2026-02-21 19:57:31 +01:00
6 changed files with 22 additions and 11 deletions
Showing only changes of commit 4cf4fb0dda - Show all commits

3
.gitignore vendored
View File

@@ -6,4 +6,5 @@ iso_root
*.iso
*.gch
*/*.gch
*/*/*.gch
*/*/*.gch
.gdb_history

View File

@@ -36,6 +36,10 @@ debug:
/usr/bin/qemu-system-x86_64 -drive file=pepper.iso -s -S -d int -no-reboot -no-shutdown &
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
/usr/bin/qemu-system-x86_64 -cdrom pepper.iso -serial stdio

View File

@@ -197,17 +197,17 @@ struct cpu_status_t* interrupt_dispatch(struct cpu_status_t* context)
case 32: // Timer Interrupt
ticks++;
// Send an EOI so that we can continue having interrupts
outb(0x20, 0x20);
if (ticks % SCHEDULER_QUANTUM == 0)
{
CLEAR_INTERRUPTS;
struct cpu_status_t* current_ctx = scheduler_schedule(context);
process_switch(current_ctx->iret_rsp, current_ctx->iret_rip);
SET_INTERRUPTS;
return scheduler_schedule(context);
//struct cpu_status_t* current_ctx = scheduler_schedule(context);
//process_switch(current_ctx->iret_rsp, current_ctx->iret_rip);
//SET_INTERRUPTS;
}
// Send an EOI so that we can continue having interrupts
outb(0x20, 0x20);
break;
case 33:

View File

@@ -35,7 +35,7 @@ void hcf()
}
// 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)));
@@ -110,12 +110,16 @@ void kmain()
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);
process_display_list(processes_list);
scheduler_init();
current_process = idle_proc;
current_process->status = RUNNING;
SET_INTERRUPTS;
keyboard_init(FR);

View File

@@ -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.
void process_exit()
{
DEBUG("Exiting from process '%s'", current_process->name);
CLEAR_INTERRUPTS;
if (current_process)
{
@@ -167,6 +168,7 @@ void process_exit()
}
SET_INTERRUPTS;
outb(0x20, 0x20);
for (;;)
{
asm("hlt");

View File

@@ -8,6 +8,7 @@
#include "process.h"
#include "mem/paging/paging.h"
#include <stdint.h>
#include "io/serial/serial.h"
extern struct process_t* processes_list;
extern struct process_t* current_process;
@@ -20,7 +21,7 @@ void scheduler_init()
struct cpu_status_t* scheduler_schedule(struct cpu_status_t* context)
{
//current_process->context = context;
current_process->context = context;
current_process->status = READY;
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));
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;
}