HLT

In the x86 computer architecture, HLT (halt) is an assembly language instruction which halts the CPU until the next external interrupt is fired.[1] Such interrupts are used by devices to signal to CPU that an event occurred which the CPU shall react on. Hardware timers can also signal an interrupt to the CPU in order to execute timed work.

The HLT instruction is executed by the operating system when there is no immediate work to be done, and the system enters its idle state. In Windows NT, for example, this instruction is run in the "System Idle Process".

On x86 processors, the opcode of HLT is 0xF4.

Contents

Process

Almost every reasonably modern processor instruction set includes an instruction or sleep mode which halts the processor until more work needs to be done. In interrupt driven processors, this instruction halts the CPU until an external interrupt is received. On most architectures, executing such an instruction allows the processor to significantly reduce its power usage and heat output, which is why it is commonly used instead of busy waiting to reduce power consumption and heat.

Use in operating systems

Since issuing the HLT instruction requires ring 0 access, it can only be run by privileged system software, such as the kernel. Because of this, it is often best practice in application programming to use the API provided for that purpose by the operating system when no more work can be done. This is referred to as "yielding" the processor. This allows the operating system's scheduler to decide if other processes are runnable; if not, it will normally issue the HLT instruction to cut power usage.

See also

References