Integration of scheduler into pit.c

This commit is contained in:
Adrien Bourmault 2020-02-02 14:21:15 +01:00
parent 1b59decd0f
commit f30e2a1d4c
4 changed files with 24 additions and 28 deletions

View File

@ -86,6 +86,9 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
// ACPI
IoTestAcpi();
// Scheduler
PsInitSched();
// Command line (kernel mode)
ShStartShell();

View File

@ -153,7 +153,7 @@ void KeSetupIDT(void)
KeSetIDTGate(0x1F, (ulong)isr31, codeSeg, 0x8E, 2); // INTEL RESERVED
// Set IDT IRQs Gates
KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 3);
KeSetIDTGate(0x20, (ulong)isr32, codeSeg, 0x8E, 0);
KeSetIDTGate(0x21, (ulong)isr33, codeSeg, 0x8E, 3);
KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 3);
KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 3);

View File

@ -25,6 +25,7 @@
#include <lib/buf.h>
#include <ke/time.h>
#include <ke/idt.h>
#include <ke/sched.h>
#define COUNTDONE 1
#define PIT_FREQUENCY 1000 // Hz = 1ms
@ -34,6 +35,8 @@ static ulong Ticks = 0;
static Time_t CurTime;
static char TimeFmtBuf[22] = { 0 };
extern bool PsInitialized;
//
// ISR handler for the Programmable Interval Timer
//
@ -53,6 +56,10 @@ static void HandlePIT(ISRFrame_t *regs)
}
KeSendEOItoPIC(0x28);
if (PsInitialized && !(Ticks % 100)) {
PsSchedOnTick();
}
}
}
#pragma GCC pop_options

View File

@ -26,6 +26,9 @@
#include <ke/proc.h>
#include <ke/sched.h>
#include <lib/list.h>
#include <ke/time.h>
bool PsInitialized = false;
//
// For test purpose only
@ -302,6 +305,8 @@ void PsInitSched(void)
}
PsUnlockSched();
PsInitialized = true;
}
//
@ -311,6 +316,8 @@ void PsFiniSched(void)
{
assert(IdlePrioProcs && ReglPrioProcs && ServPrioProcs && TimeCritProcs);
PsInitialized = false;
PsLockSched();
while (IdlePrioProcs->length > 0)
@ -372,38 +379,17 @@ void pstest(void)
KernLog("\nIdle: ");
PrintList(IdlePrioProcs);
int tick = 0;
KernLog("\n");
while (tick < 100) {
//if (tick%25==0)ClearTerm(StdOut);
if (tick > 0 && tick != 50 && tick % 10 == 0 && KeCurProc) {
KernLog("Blocking current process\n");
PsBlockCurProc();
}
if (tick == 50) {
procs[0].procState = STATE_RUNNABLE;
PsSchedThisProc(&procs[0]);
}
KernLog("Tick %d - Running: ", KeGetTicks());
KernLog("Tick %d - Running: ", tick);
if (KeCurProc == NULL) {
KernLog("IDLE\n");
}
if (KeCurProc == NULL) {
KernLog("IDLE\n");
}
else {
PrintProc(KeCurProc);
}
PsSchedOnTick();
if (tick == 50) // already done
KernLog("Re-scheduling process 0\n");
tick++;
else {
PrintProc(KeCurProc);
}
}