Modified Sleep, now Sleep(0) calls hlt one time

This commit is contained in:
ralfkronemeyer_cp 2008-06-25 21:49:30 +00:00
parent 70432fb9eb
commit 4a4744082b

View file

@ -36,14 +36,17 @@ namespace Cosmos.Hardware {
TickCount++; TickCount++;
} }
//TODO: Change this to use an x86 Op or something so it doesnt
// just thrash
public static void Sleep(uint aMSec) { public static void Sleep(uint aMSec) {
uint xStart = TickCount;
uint xEnd = xStart + aMSec;
Cosmos.Hardware.DebugUtil.SendNumber("PC", "Sleep", aMSec, 32); Cosmos.Hardware.DebugUtil.SendNumber("PC", "Sleep", aMSec, 32);
while (TickCount < xEnd) { CPU.Halt();//At least one hlt even if aMSec is 0
CPU.Halt(); if (aMSec > 0)
{
uint xStart = TickCount;
uint xEnd = xStart + aMSec;
while (TickCount < xEnd)
{
CPU.Halt();
}
} }
Cosmos.Hardware.DebugUtil.SendMessage("PC", "Sleeping done"); Cosmos.Hardware.DebugUtil.SendMessage("PC", "Sleeping done");
} }