In a multitasking operating system, it is possible for an individual
process or
thread to get stuck, such as blocking on a resource or getting into an infinite loop, though the effect on the overall system varies significantly. In a
cooperative multitasking system, any thread that gets stuck without yielding will hang the system, as it will
wedge itself as the running thread and prevent other threads from running. By contrast, modern operating systems primarily use
pre-emptive multitasking, such as
Windows 2000 and its successors, as well as
Linux and
Apple Inc.'s
macOS. In these cases, a single thread getting stuck will not necessarily hang the system, as the operating system will preempt it when its time slice expires, allowing another thread to run. If a thread does hang, the scheduler may switch to another group of interdependent tasks so that all processes will not hang. However, a stuck thread will still consume resources: at least an entry in scheduling, and if it is running (for instance, stuck in an infinite loop), it will consume processor cycles and power when it is scheduled, slowing the system though it does not hang it. However, even with preemptive multitasking, a system can hang, and a misbehaved or malicious task can hang the system, primarily by monopolizing some other resource, such as IO or memory, even though processor time cannot be monopolized. For example, a process that blocks the file system will often hang the system. Moving around a
window on top of a hanging program during a hang may cause a window trail from redrawing. == Causes ==