PIT & BIOS
Posted: Thu Mar 05, 2015 7:35 am
Actually it doesn't, lol.omarrx024 wrote:The PIT does the task switching.
Actually it doesn't, lol.omarrx024 wrote:The PIT does the task switching.
Actually, it does. I have my PIT IRQ handler do the task switching.ExeTwezz wrote:Actually it doesn't, lol.
Oops, my mistake. I meant the PIT IRQ handler.Combuster wrote:Which still means the PIT itself doesn't do the actual task switching.
Hehe.Roflo wrote:Actually the pit irq handler doesn't do the task switching but the cpu
I thought your OS used BIOS calls. How exactly do you use task-switching? The BIOS isn't pre-emptible..?omarrx024 wrote:Multitasking support!
The shot shows two tasks running. The first task prints "1" and the second task prints "2." The PIT IRQ handler does the task switching.
I installed a custom IRQ handler for the PIT. This custom handler checks for running tasks and switches between them. And besides, task switching doesn't depend on GDT, TSS and other 32-bit stuff. There is nothing wrong with creating your own custom structures and things. In fact, it is even more customizable and easy this way. Who ever said that multitasking cannot be done in 16-bit mode?bace wrote:I thought your OS used BIOS calls. How exactly do you use task-switching? The BIOS isn't pre-emptible..?
Yes. Whenever a PIT IRQ occurs, I save the return EIP address and save SS and SP. Then when my PIT IRQ handler returns and the other running tasks finish running, it saves the state of other tasks and restores the stack of the BIOS code. It then jumps back to the BIOS code.bace wrote:No, I mean, how do you preempt tasks running BIOS code? This has nothing to do with you being in real mode.
You can't just stop a BIOS call midway, call a few others, and expect it to return to the original one (as far as I know). Is that what you're currently doing?
try doing that while accessing the harddrive could destroy your computer (depending on exact instant the PIT interrupt occurs) even if it doesn't, it definitely won't work correctly -- best case, the BIOS function will fail (return carry set) worst case the computer will be physically damaged, more likely it will succeed (return carry clear) but the expected action won't happen, and something else will instead (like reading or writing the wrong disk sectors, causing major data corruption)omarrx024 wrote:Yes. Whenever a PIT IRQ occurs, I save the return EIP address and save SS and SP. Then when my PIT IRQ handler returns and the other running tasks finish running, it saves the state of other tasks and restores the stack of the BIOS code. It then jumps back to the BIOS code.bace wrote:No, I mean, how do you preempt tasks running BIOS code? This has nothing to do with you being in real mode.
You can't just stop a BIOS call midway, call a few others, and expect it to return to the original one (as far as I know). Is that what you're currently doing?
Come to think of it, the code that tests my multitasking (the code that prints "1" and "2" as seen in the screenshot) uses BIOS INT 0x10.