sched: reschedule on sched interrupt

This commit is contained in:
Michael Shaw 2024-06-17 18:00:32 -04:00
commit f86ce66c75
4 changed files with 7 additions and 4 deletions

View file

@ -137,7 +137,7 @@ void apic_enable_timer()
lapic_write(lapic_addr, LAPIC_TIMER_DIV, 0x3); lapic_write(lapic_addr, LAPIC_TIMER_DIV, 0x3);
/* set timer initial count */ /* set timer initial count */
lapic_write(lapic_addr, LAPIC_TIMER_INIT_COUNT, 0xFFFFFFFF); lapic_write(lapic_addr, LAPIC_TIMER_INIT_COUNT, 0xFFFFFF);
/* set timer vector and enable */ /* set timer vector and enable */
lapic_write(lapic_addr, LAPIC_TIMER, 0x20 | 0x20000); lapic_write(lapic_addr, LAPIC_TIMER, 0x20 | 0x20000);

View file

@ -133,6 +133,7 @@ void apic_init();
void lapic_eoi(); void lapic_eoi();
int madt_parse_next_entry(int offset); int madt_parse_next_entry(int offset);
void lapic_enable(); void lapic_enable();
void apic_enable_timer();
uint8_t lapic_idno(); uint8_t lapic_idno();
#endif /* __ASM__ */ #endif /* __ASM__ */

View file

@ -214,6 +214,8 @@ void kmain()
irq_map(0, trap_sched); irq_map(0, trap_sched);
apic_enable_timer();
kprintf("\n"); kprintf("\n");
prompt(); prompt();
load_stack_and_park(ptr, ptr); load_stack_and_park(ptr, ptr);

View file

@ -130,7 +130,8 @@ void proc_term(pid_t pid)
void trap_sched() void trap_sched()
{ {
kprintf("trap_sched\n"); lapic_eoi();
schedule();
} }
void schedule() void schedule()
@ -146,7 +147,7 @@ void schedule()
} }
size_t counter = 0; size_t counter = 0;
size_t limit = 256; size_t limit = 1000000;
while (counter++ < limit) { while (counter++ < limit) {
/* next process */ /* next process */
proc = proc_next(proc); proc = proc_next(proc);
@ -168,7 +169,6 @@ void schedule()
} }
} }
kprintf(LOG_ERROR "schedule: no runnable processes\n");
sti(); sti();
yield(); yield();
} }