Page 1 of 1

Wait() problem

Posted: Sun Aug 07, 2005 1:25 am
by Tora OS
Well when CTRL+ALT+DEL is pressed the function below is fired. It should print a message warning of reboot in 10 seconds, switch the virtural console to console 1, wait 10 seconds, and print a reboot message and finally reboot, but it doesnt do that.

It simply prints the message, switches the virtual console and sits there. Doing nothing. Never reboots. never even prints the reboot message. Any ideas?

Ok..first the control alt del function:

Code: Select all

void CTRLATLDEL()
{
//function fired when CTRL ALT DEL is pressed. waits 10 seconds...then reboots.
vc_printf("Rebooting in 10 Seconds....",1);
switch_vc(1);
wait(10);
vc_printf("Rebooting...",1);
reboot();
vc_printf("You should not see this message.",1);
now for the timer function:

Code: Select all

int timer_ticks = 0;

//IRQ errr 0 Handler:
void timer_handler(struct regs *r)
{
    // Add 1 to our ticks used by things in TIMER.C (GLOBAL eventualy??? UNIVERSAL??? LOLNO)
    timer_ticks++;
}

//Wait function:
void wait(int seconds)
{
    unsigned long end_ticks;
    unsigned long my_ticks;

    my_ticks = seconds * 18; //multiply the seconds times 18 because of the ibm dudes on drugs back when they made that value.
   
    end_ticks = timer_ticks + my_ticks; //figuer out how what our ending value for ticks will be.
    while(timer_ticks < end_ticks); //do nothing until the elapsed time has passed.
}

void timer_install()
{
    //install the IRQ handler for IRQ0
    irq_install_handler(0, timer_handler);
}

Re:Wait() problem

Posted: Sun Aug 07, 2005 7:57 am
by gaf
Hello,
I think you have to declare timer_ticks as volatile to avoid that the optimizer caches it in one of the CPU regs..

regards,
gaf