Integration of scheduler into pit.c
This commit is contained in:
parent
1b59decd0f
commit
f30e2a1d4c
|
@ -86,6 +86,9 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
||||||
// ACPI
|
// ACPI
|
||||||
IoTestAcpi();
|
IoTestAcpi();
|
||||||
|
|
||||||
|
// Scheduler
|
||||||
|
PsInitSched();
|
||||||
|
|
||||||
// Command line (kernel mode)
|
// Command line (kernel mode)
|
||||||
ShStartShell();
|
ShStartShell();
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ void KeSetupIDT(void)
|
||||||
KeSetIDTGate(0x1F, (ulong)isr31, codeSeg, 0x8E, 2); // INTEL RESERVED
|
KeSetIDTGate(0x1F, (ulong)isr31, codeSeg, 0x8E, 2); // INTEL RESERVED
|
||||||
|
|
||||||
// Set IDT IRQs Gates
|
// 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(0x21, (ulong)isr33, codeSeg, 0x8E, 3);
|
||||||
KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 3);
|
KeSetIDTGate(0x22, (ulong)isr34, codeSeg, 0x8E, 3);
|
||||||
KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 3);
|
KeSetIDTGate(0x23, (ulong)isr35, codeSeg, 0x8E, 3);
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <lib/buf.h>
|
#include <lib/buf.h>
|
||||||
#include <ke/time.h>
|
#include <ke/time.h>
|
||||||
#include <ke/idt.h>
|
#include <ke/idt.h>
|
||||||
|
#include <ke/sched.h>
|
||||||
|
|
||||||
#define COUNTDONE 1
|
#define COUNTDONE 1
|
||||||
#define PIT_FREQUENCY 1000 // Hz = 1ms
|
#define PIT_FREQUENCY 1000 // Hz = 1ms
|
||||||
|
@ -34,6 +35,8 @@ static ulong Ticks = 0;
|
||||||
static Time_t CurTime;
|
static Time_t CurTime;
|
||||||
static char TimeFmtBuf[22] = { 0 };
|
static char TimeFmtBuf[22] = { 0 };
|
||||||
|
|
||||||
|
extern bool PsInitialized;
|
||||||
|
|
||||||
//
|
//
|
||||||
// ISR handler for the Programmable Interval Timer
|
// ISR handler for the Programmable Interval Timer
|
||||||
//
|
//
|
||||||
|
@ -53,6 +56,10 @@ static void HandlePIT(ISRFrame_t *regs)
|
||||||
}
|
}
|
||||||
|
|
||||||
KeSendEOItoPIC(0x28);
|
KeSendEOItoPIC(0x28);
|
||||||
|
|
||||||
|
if (PsInitialized && !(Ticks % 100)) {
|
||||||
|
PsSchedOnTick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma GCC pop_options
|
#pragma GCC pop_options
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#include <ke/proc.h>
|
#include <ke/proc.h>
|
||||||
#include <ke/sched.h>
|
#include <ke/sched.h>
|
||||||
#include <lib/list.h>
|
#include <lib/list.h>
|
||||||
|
#include <ke/time.h>
|
||||||
|
|
||||||
|
bool PsInitialized = false;
|
||||||
|
|
||||||
//
|
//
|
||||||
// For test purpose only
|
// For test purpose only
|
||||||
|
@ -302,6 +305,8 @@ void PsInitSched(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
PsUnlockSched();
|
PsUnlockSched();
|
||||||
|
|
||||||
|
PsInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -311,6 +316,8 @@ void PsFiniSched(void)
|
||||||
{
|
{
|
||||||
assert(IdlePrioProcs && ReglPrioProcs && ServPrioProcs && TimeCritProcs);
|
assert(IdlePrioProcs && ReglPrioProcs && ServPrioProcs && TimeCritProcs);
|
||||||
|
|
||||||
|
PsInitialized = false;
|
||||||
|
|
||||||
PsLockSched();
|
PsLockSched();
|
||||||
|
|
||||||
while (IdlePrioProcs->length > 0)
|
while (IdlePrioProcs->length > 0)
|
||||||
|
@ -372,23 +379,10 @@ void pstest(void)
|
||||||
KernLog("\nIdle: ");
|
KernLog("\nIdle: ");
|
||||||
PrintList(IdlePrioProcs);
|
PrintList(IdlePrioProcs);
|
||||||
|
|
||||||
int tick = 0;
|
|
||||||
|
|
||||||
KernLog("\n");
|
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) {
|
KernLog("Tick %d - Running: ", KeGetTicks());
|
||||||
procs[0].procState = STATE_RUNNABLE;
|
|
||||||
PsSchedThisProc(&procs[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
KernLog("Tick %d - Running: ", tick);
|
|
||||||
|
|
||||||
if (KeCurProc == NULL) {
|
if (KeCurProc == NULL) {
|
||||||
KernLog("IDLE\n");
|
KernLog("IDLE\n");
|
||||||
|
@ -397,13 +391,5 @@ void pstest(void)
|
||||||
else {
|
else {
|
||||||
PrintProc(KeCurProc);
|
PrintProc(KeCurProc);
|
||||||
}
|
}
|
||||||
|
|
||||||
PsSchedOnTick();
|
|
||||||
|
|
||||||
if (tick == 50) // already done
|
|
||||||
KernLog("Re-scheduling process 0\n");
|
|
||||||
|
|
||||||
tick++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue