HOME

TheInfoList



OR:

In the
x86 x86 (also known as 80x86 or the 8086 family) is a family of complex instruction set computer (CISC) instruction set architectures initially developed by Intel based on the Intel 8086 microprocessor and its 8088 variant. The 8086 was intr ...
computer architecture In computer engineering, computer architecture is a description of the structure of a computer system made from component parts. It can sometimes be a high-level description that ignores details of the implementation. At a more detailed level, the ...
, HLT (halt) is an assembly language instruction which halts the
central processing unit A central processing unit (CPU), also called a central processor, main processor or just Processor (computing), processor, is the electronic circuitry that executes Instruction (computing), instructions comprising a computer program. The CPU per ...
(CPU) until the next external
interrupt In digital computers, an interrupt (sometimes referred to as a trap) is a request for the processor to ''interrupt'' currently executing code (when permitted), so that the event can be processed in a timely manner. If the request is accepted, ...
is fired. Interrupts are signals sent by hardware devices to the CPU alerting it that an event occurred to which it should react. For example, hardware timers send interrupts to the CPU at regular intervals. Most
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s execute a HLT instruction when there is no immediate work to be done, putting the processor into an idle state. In
Windows NT Windows NT is a proprietary graphical operating system produced by Microsoft, the first version of which was released on July 27, 1993. It is a processor-independent, multiprocessing and multi-user operating system. The first version of Win ...
, for example, this instruction is run in the " System Idle Process". On x86 processors, the opcode of HLT is 0xF4.


History on x86

All x86 processors from the 8086 onward had the HLT instruction, but it was not used by
MS-DOS MS-DOS ( ; acronym for Microsoft Disk Operating System, also known as Microsoft DOS) is an operating system for x86-based personal computers mostly developed by Microsoft. Collectively, MS-DOS, its rebranding as IBM PC DOS, and a few ope ...
prior to 6.0 and was not specifically designed to reduce power consumption until the release of the
Intel DX4 IntelDX4 is a clock-tripled i486 microprocessor with 16-kB Level 1 cache.http://www.pld.ttu.ee/~prj/486dev.pdf Intel named it DX4 (rather than ''DX3'') as a consequence of litigation with AMD over trademarks. The product was officially n ...
processor in 1994. MS-DOS 6.0 provided a POWER.EXE that could be installed in CONFIG.SYS and in Microsoft's tests it saved 5%. Some of the first 100 MHz DX chips had a buggy HLT state, prompting the developers of
Linux Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
to implement a "no-hlt" option for use when running on those chips, but this was fixed in later chips. Intel has since introduced additional processor-yielding instructions. These include: * in SSE2 intended for spin loops. Available to userspace (low-privilege rings). * / in
SSE3 SSE3, Streaming SIMD Extensions 3, also known by its Intel code name Prescott New Instructions (PNI), is the third iteration of the SSE instruction set for the IA-32 (x86) architecture. Intel introduced SSE3 in early 2004 with the Prescott revis ...
for thread synchronization. * (timed pause) and / (userspace monitor/mwait). Available to userspace.


Process

Almost every 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 In computer science and software engineering, busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available. Spinning can also be use ...
for sleeping and idling. In most processors, halting (instead of looping) also reduces the latency of the next interrupt.


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 Kernel may refer to: Computing * Kernel (operating system), the central component of most operating systems * Kernel (image processing), a matrix used for image convolution * Compute kernel, in GPGPU programming * Kernel method, in machine learn ...
. Because of this, it is often best practice in application programming to use the application programming interface (API) provided for that purpose by the operating system when no more work can be done, such as Linux's sched_yield(). This is referred to as "yielding" the processor. This allows the operating system's
scheduler A schedule or a timetable, as a basic time-management tool, consists of a list of times at which possible tasks, events, or actions are intended to take place, or of a sequence of events in the chronological order in which such things are i ...
to decide whether other processes are runnable; if not. If every process is sleeping or waiting, it will normally execute a HLT instruction to cut power usage until the next hardware interrupt.


See also

*
Advanced Configuration and Power Interface Advanced Configuration and Power Interface (ACPI) is an open standard that operating systems can use to discover and configure computer hardware components, to perform power management (e.g. putting unused hardware components to sleep), auto co ...
(ACPI) *
Advanced Power Management Advanced power management (APM) is an API developed by Intel and Microsoft and released in 1992 which enables an operating system running an IBM-compatible personal computer to work with the BIOS (part of the computer's firmware) to achieve power ...
(APM) *
Computer architecture In computer engineering, computer architecture is a description of the structure of a computer system made from component parts. It can sometimes be a high-level description that ignores details of the implementation. At a more detailed level, the ...
* Halt and Catch Fire *
Idle (CPU) A computer processor is described as idle when it is not being used by any program. Every program or task that runs on a computer system occupies a certain amount of processing time on the CPU. If the CPU has completed all tasks it is idle. Mode ...
* Instruction set architecture *
NOP (code) In computer science, a NOP, no-op, or NOOP (pronounced "no op"; short for no operation) is a machine language instruction and its assembly language mnemonic, programming language statement, or computer protocol command that does nothing. Mac ...


References

{{Reflist, 30em Machine code X86 instructions