Re: Scheduling extremely inefficient
Posted: Tue Mar 17, 2015 1:30 pm
No, sorryGeri wrote:is there a 32-bit version available?
The Place to Start for Operating System Developers
http://forum.osdev.org./
No, sorryGeri wrote:is there a 32-bit version available?
So, if there's 100 tasks that happen to be in the order "video driver, GUI, application, keyboard driver, 96 other things", then:mariuszp wrote:https://github.com/madd-games/glidix/bl ... glidix.isoGeri wrote:you should have linked an ISO, so we could debug it.
Also, indeed, my scheduler does not support priorities, and the PIT is fixed at a frequency of 1000 Hz, even though some processes call yield() to give up their CPU time... but then the next process would get much less CPU time than normal... that does sound like a pretty bad design. And drivers like the IDE driver and the keyboard driver are just hanging there waiting for commands and still getting CPU time.
"Disabling" interrupts (e.g. with the CLI instruction) only causes interrupts to be postponed (until the CPU is able to receive them again) and doesn't cause IRQs to be discarded.mariuszp wrote:I'm gonna be adding APIC support and here's a question: if I set APIC to single-shot mode, and that "shot" happens when interrupts are disabled, is it missed or does it get sent as soon as I enable interrupts? What about if interrupts are disabled, the shot happens, then I program the APIC again, and then enable interrupts? (I'll need to do that for calls such as wait() which would need to trigger the scheduler to schedule another task).
Why are IRQs disabled in the first place? How much data are you copying? How does PDCLib implement 'memcpy()'?mariuszp wrote:(EDIT: I may also add that calling memcpy() while interrupts are disabled also causes the swap to screen to take a few seconds, is that a Bochs problem or could the memcpy() implementation I 'stole' from PDCLib be really bad and I should use "rep stosb" instead?)
my emulator supports 32-bit only, so i cant debug your system.mariuszp wrote:No, sorryGeri wrote:is there a 32-bit version available?
I only disabled them to test performance this one time. The PDCLib implementation is just the good old "*dst++ = *src++".Brendan wrote:Why are IRQs disabled in the first place?
That might work (depending on a lot of things, like what other code uses that spinlock and whether or not anything needs to set the local APIC count without enabling IRQs).mariuszp wrote:As for the race conditinos you mentioned, how about this: I first lock the APIC spinlock, then disable interrupts, then program the APIC, then enable interrupts, and finally release the spinlock. This means that if an APIC IRQ occured during the interrupts-disabled period, it will be sent right after STI is executed. The APIC IRQ handler will then try locking the spinlock, and if that fails, it will just return, and then the spinlock will be released by the APIC programming code.
That works out to about 1 MiB per second, which might be fast (if it's Bochs running on top of an old slow computer) or slow (if it's running on a modern real computer and not inside a virtual machine).mariuszp wrote:Oh, and I was just copying 800*600*4 bytes of data into video memory (just white pixels). No matter if I use memcpy() or memset(), even with interrupts disabled, it takes a few seconds to copy this single frame.