bughunter wrote:I've been reading some topics about Memory Management and I often notice people talk about disabling interrupts in various parts of the Memory Management functions. Would disabling interrupts stop the mouse too?
The mouse driver would be unable to process interrupts while they're disabled, yes.
I mean, you can't move the mouse when interrupts are disabled, or am I crazy now?
No, that sounds about right. (Though you can obviously move the physical mouse, the messages it sends won't be processed by the kernel until it responds to the interrupt generated so the cursor wouldn't be moved yet)
I made a little program that allocates and frees 100 megabyte blocks in a loop that iterates 1 million times.
Typically when interrupts are disabled, they're not disabled for very long. As long as the mouse only sends one interrupt in that time you should be fine; the interrupt will be processed as soon as they're enabled again (and any higher-priority interrupts have been processed).
Note: I have no idea what happens when there are multiple unhandled messages. It may even differ for serial, PS/2 and USB mice...
The host OS is Windows in my case, and the mouse didn't even stutter (and I even put my mouse at 2000 DPI).
Can anyone shed some light on this
![Wink :wink:](./images/smilies/icon_wink.gif)
If you're testing this in Windows, you're most likely using user-level malloc/free or new/delete instead of kernel-level memory management functions. these user-level memory management functions don't normally need a lot of interaction from the kernel-level MM (and can't themselves disable interrupts - though they typically perform some form of locking if they're threadsafe). They just request memory from the kernel MM when they run out, and normally don't release it when it's free'd but reuse it for later allocations instead.
However 100MB allocs might be exceptions, I seem to recall dlmalloc optionally using memory-mapped files for large allocations. Other malloc implementations may do something similar. Still, the system calls those require shouldn't disable interrupts for very long either. In fact, pretty much nothing should except stuff like BSODs/kernel panics.