I tried:Techel wrote:Did you enable realtime sync in bochs?
Code: Select all
vga: realtime=1
I tried:Techel wrote:Did you enable realtime sync in bochs?
Code: Select all
vga: realtime=1
So Bochs is spending 100% of host CPU time emulating devices (e.g. updating the screen, checking if an IRQ occurred, etc) and the guest CPU is spending most of it's time idle.mohammedisam wrote:I am testing my kernel using Bochs under Fedora Linux. The GNOME System Monitor shows that at any given time (when my kernel is active) one of my quad processors is running at 100%. When I pause Bochs, the activity returns to its baseline (3-4%). If it runs for a while, all my other programs would considerably slow down, so I have to test my kernel after I close other windows.gerryg400 wrote:How do you know that it's busy?
Why?mohammedisam wrote:Looks like I will have to live with it. I cannot risk testing it on physical device yet.onlyonemac wrote:Most emulators, especially Bochs, will use all available CPU power even when the emulated CPU is supposed to be idle.
How would even think that would make sense to even try!? Learn to read documentation!mohammedisam wrote:...in my bochsrc.txt file before, it didn't change a thing: same high readings for cpu performance.Code: Select all
vga: realtime=1
I haven't implemented this feature yet (keeping track of task times), though I see now this is the next step I should do.Brendan wrote: If you have a specific "idle task", then an extremely easy alternative is to keep track of how much CPU time each task consumes (which is something you should be doing anyway); and then determine CPU load as "(total - idle) / total". Of course this will be a lot less accurate (e.g. time taken by IRQ handlers that interrupt the idle task will be counted as "idle time"); unless you keep track of "user time" and "kernel time" separately for each task and also use a very precise time source (like the CPU's TSC and not the "only updated every 10 ms" PIT timer count).
actually, this is exactly the case. My disk drivers are still under development this is why I am not eager to try it on my physical drive yet. I am still in the phase of testing on virtual disk images.Brendan wrote: Except for a few obvious cases (e.g. you're trying to implement hard disk drivers that write to the disk) there's almost no risk involved in testing on real computers. By not testing on real computers there's a high risk of undiscovered bugs.
I will. Thanks man .SpyderTL wrote:Try testing on VirtualBox. If your virtual CPU is halted between interrupts, your VirtualBox host CPU usage will got to zero, or close to it.
That depends on the emulator, but as we've already mentioned Bochs will keep the host CPU busy while according to SpyderTL VirtualBox apparently lets the host CPU idle when the emulated CPU is idle.mohammedisam wrote:Just to make sure I got this right: it is normal for emulators to keep the host CPU busy, though this doesn't reflect the normal behavior on a real physical device, right?
Define "disk drivers". If you mean floppy disk drivers, then there's no reason not to test on real hardware. If you mean hard disk drivers, then pull them out of your OS and boot it from a floppy. You could also remove (or disconnect) the hard drive from your test machine.mohammedisam wrote:actually, this is exactly the case. My disk drivers are still under development this is why I am not eager to try it on my physical drive yet. I am still in the phase of testing on virtual disk images.
Whatever, you're just picking on words.iansjack wrote:Note that VirtualBox is not an emulator.
In fact this was a great suggestion. I did try it on VirtualBox and indeed the CPU is idle when the idle task is running, using only 3-4% of the host CPU.onlyonemac wrote:That depends on the emulator, but as we've already mentioned Bochs will keep the host CPU busy while according to SpyderTL VirtualBox apparently lets the host CPU idle when the emulated CPU is idle.
I am writing the virtual file system layer (reading/editing FAT tables, Ext2 dirs/files and so on) so I expect my kernel to mess the disk pretty well. But disconnecting the hard disk is a good thought.onlyonemac wrote:Define "disk drivers". If you mean floppy disk drivers, then there's no reason not to test on real hardware. If you mean hard disk drivers, then pull them out of your OS and boot it from a floppy. You could also remove (or disconnect) the hard drive from your test machine.
Yep, I got what you and Brendan said before. That is indeed a wise move. I will be working on the clock and timer facilities soon.onlyonemac wrote: Of course, if you test on real hardware, you'll also need a way to measure CPU usage.
This is to be expected, because the CPU is not emulated in VirtualBox.mohammedisam wrote:In fact this was a great suggestion. I did try it on VirtualBox and indeed the CPU is idle when the idle task is running, using only 3-4% of the host CPU.onlyonemac wrote:That depends on the emulator, but as we've already mentioned Bochs will keep the host CPU busy while according to SpyderTL VirtualBox apparently lets the host CPU idle when the emulated CPU is idle.
The "correct" way, in my opinion, would be to let the OS call the HLT instruction, and only when there is no work to be done. The applications (threads) should call a "yield()" or "sleep()" kernel function that will notify the OS that the current thread is out of work to do, or is waiting on some specific event to happen. Then the OS can decide to swap to a different thread, if there are any threads that have work to do, or it can call the HLT instruction.DavidCooper wrote:What is the correct way to use the HLT instruction?
Any interrupt will wake up the CPU, not just the timer. So if there really is no work to do, and the OS calls the HLT instruction, it will wake back up and call the appropriate interrupt handler if the timer elapses, or if a keyboard key is pressed, or if the mouse is moved, or if a network packet is received (or sent), or if a USB device is plugged in, and so on. Then, the instruction immediately after the HLT instruction will be executed. You will actually have to call the HLT instruction again, if you want the CPU to go back to sleep.DavidCooper wrote:What should you actually do then - just let it halt and rely on timer interrupts to wake it up at some point to get the vital work done?