Page 1 of 1

A while loop

Posted: Mon Mar 17, 2003 9:08 pm
by AvengerX
how could i construct a while loop that allows execution of other system processes (in my while loop, even the system timer stops until it returns, therefore it doesnt return, because thew interrupts seem not to work)
thanks in advance.

Re:A while loop

Posted: Tue Mar 18, 2003 3:01 am
by Tim
Set up an IDT. In your IRQ 0 handler, call the scheduler. Then, before your while loop, enable interrupts.

Alternatively, call the scheduler periodically from inside the while loop.

Re:A while loop

Posted: Tue Mar 18, 2003 7:44 pm
by AvengerX
I have an IDT, and the scheduler is run by a while loop in main() (bad idea..), when i run it from both the main while loop and the loop i am using, the loop i am using never returns, and if i have no while loop in main() it'll crash, do i just have a blank while loop (or until i get my getc function (it depends on this) working, then i cna make it display a prompt)

Re:A while loop

Posted: Wed Mar 19, 2003 3:13 am
by Pype.Clicker
it's not enough to call the other process from your scheduler as a regular function call. You have to perform a task switch (either using TSSes or with a stack-switch approach)

Re:A while loop

Posted: Wed Mar 19, 2003 4:30 pm
by AvengerX
I am using a scheduler function, i've moved it into the timer int and it works, but my while loop still doesn't, and the scheduler does a long jump to the task (kernel-based tasks right now) and so forth, no TSS, etc., but i'm not calling each task seperately

Re:A while loop

Posted: Thu Mar 20, 2003 9:41 am
by Pype.Clicker
when your scheduler is in the timer IRQ, it is called regardless of what the tasks do, and it can perform the switch.

If you just write a task that do

Code: Select all

while(1) schedule();
, what will call your scheduler when it is in another task ...

i think that's where your problem comes from ...