sleep function.. please help
Posted: Wed Jun 04, 2003 8:28 am
Hello, i need a sleep funktion like sleep(5000), so that my OS sleep 5 seconds. I have a PIT and a init_timer function (see below).
Now, how can i realize a sleep function?? I have no idea and not found any examples or good informations about this in the forum and google. :'(
please help.. thx Wacky
My PIT:
My init_timer:
In my main-function i'm calling:
Now, how can i realize a sleep function?? I have no idea and not found any examples or good informations about this in the forum and google. :'(
please help.. thx Wacky
My PIT:
Code: Select all
#define PIC1 0x20
#define PIC2 0xA0
#define ICW1 0x11
#define ICW4 0x01
#define PIT_CTRL 0x43
#define PIT_CH_0 0x40
void init_pics(int pic1, int pic2)
{
outportb(PIC1, ICW1);
outportb(PIC2, ICW1);
outportb(PIC1 + 1, pic1);
outportb(PIC2 + 1, pic2);
outportb(PIC1 + 1, 4);
outportb(PIC2 + 1, 2);
outportb(PIC1 + 1, ICW4);
outportb(PIC2 + 1, ICW4);
outportb(PIC1 + 1, 0xFF);
}
Code: Select all
init_timer(unsigned char FREQ)
{
unsigned int counter=1193181/FREQ;
outportb(PIT_CTRL, 0x34);
outportb(PIT_CH_0, counter%256);
outportb(PIT_CH_0, counter/256);
}
Code: Select all
init_pics(0x20, 0x28);
init_timer(100);