A while loop

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
AvengerX

A while loop

Post 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.
Tim

Re:A while loop

Post 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.
AvengerX

Re:A while loop

Post 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)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:A while loop

Post 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)
AvengerX

Re:A while loop

Post 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
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:A while loop

Post 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 ...
Post Reply