For Windows, a more complete answer is that:
[ul]
[li]User-mode threads run at IRQL = PASSIVE_LEVEL (IRQL = 0 on x86)[/li][li]Thread rescheduling is done at IRQL = DISPATCH_LEVEL/DPC_LEVEL (IRQL = 2). Often, it is invoked as a Deferred Procedure Call (DPC).[/li][li]Normal hardware device Interrupt Service Routines (ISRs) operate at IRQL = device IRQL (DIRQL). (IRQL = 3-26 decimal)[/li][li]The real time clock ISR operates at IRQL = CLOCK_LEVEL (IRQL = 28).[/li][/ul]
The catch is that when the system is at a given IRQL, it cannot be interrupted to do work of equal lesser IRQL. In other words, when the IRQL is above DISPATCH/DPC_LEVEL, thread rescheduling cannot occur. It does not matter how high you set the thread priority, it will not even be scheduled to run a core until at least one core in the system is running at IRQL < DISPATCH/DPC_LEVEL. Furthermore, any threads scheduled for execution won’t actually run until IRQL = PASSIVE_LEVEL (or APC_LEVEL in the case of some kernel mode threads).
Because of this, kernel mode software tries to run below DISPATCH/DPC_LEVEL as much as possible. When the clock ISR fires, it is running at CLOCK_LEVEL, which not only blocks thread rescheduling, but also blocks device drivers. This is not a good condition, so the only thing it does at this level is to update some kernel timers and counters, and check if rescheduling needs to occur. If it does, the clock ISR makes a deferred procedure call to the scheduler, and exits as early as possible. The rescheduling (picking the best thread to run next) will happen whenever the IRQL drops to (or through) DISPATCH/DPC_LEVEL.
Similarly, device drivers try to as little work as possible at DIRQL level. For instance, a USB controller is going to take the data it reads from the bus and stuff it in a memory buffer somewhere, and do whatever bare minimum is needed to acknowledge receipt so that the controller can continue its operation. Actually processing that data will generally be deferred by a DPC to some other function of the driver.
Whenever you move your mouse, it transmits data on the USB bus (we’ll assume that’s what you have). The USB controller picks up this data and generates a hardware interrupt. The driver is invoked at DIRQL, which is greater than DISPATCH/DPC_LEVEL. Eventually, the USB driver will identify this data, and pass it off to the mouse driver. The mouse driver will update a kernel structure in memory representing the mouse position, register mouse clicks for synchronization objects (programs waiting for click events) and make some function calls to the window manager (aero in Vista/Win 7, GDI in Win XP) to redraw the mouse cursor. All of this will likely be done in a deferred procedure call, which runs at DISPATCH/DPC_LEVEL.
Here’s the point: mouse movement is more resistant to freezes because it is handled by code running at DISPATCH/DPC_LEVEL at the behest of code invoked at DIRQL level. Suppose that some buggy device driver is queuing up an excessive number of DPCs. This blocks thread rescheduling entirely until the queue is emptied. However, it won’t (probably) block DIRQL level interrupts, so the mouse driver is still able to inject its own DPCs into the queue. The result is that user applications freeze, but the mouse can still be moved around.
Other OSes have different architectures, and I’m not sure this exact behavior would occur on either Mac or Linux. Linux allows user mode processes running as root (UID=0) to make a system call which lowers the I/O privilege level, granting direct hardware access from user mode. Thus the X server (windowing environment) runs as a normal user mode process. If something gets tied up in the kernel, the mouse driver kernel module may still continue to function, but the X server won’t be able to respond to it.
Mac OS is derived from BSD and the Mach 3 kernel. This is a microkernel architecture which takes things even further than Linux. I’d wager that the mouse driver in Mac is a regular user process, but then, so is just about everything else. Having not used Mac myself, I can’t say how that makes things play out.