In the x86 computer architecture , HLT (halt) is an assembly language instruction which halts the central processing unit (CPU) until the next external interrupt 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.
14-677: [REDACTED] Look up hlt in Wiktionary, the free dictionary. HLT may refer to: Computing [ edit ] HLT (x86 instruction) Human language technology Places [ edit ] Hamilton Airport (Victoria) , Australia Harrah's Lake Tahoe , a casino hotel in Stateline, Nevada, United States Harveys Lake Tahoe , another casino hotel in Stateline Other uses [ edit ] Hilton Worldwide ,
28-406: A HLT instruction when there is no immediate work to be done, putting the processor into an 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 . On ARM processors, the similar instructions are WFI (Wait For Interrupt) and WFE (Wait For Event). All x86 processors from the 8086 onward had
42-466: 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: 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
56-856: A delay function (e.g., sleep() ) found in most operating systems. This puts a thread to sleep for a specified time, during which the thread will waste no CPU time. If the loop is checking something simple then it will spend most of its time asleep and will waste very little CPU time. In programs that never end (such as operating systems), infinite busy waiting can be implemented by using unconditional jumps as shown by this NASM syntax: jmp $ . The CPU will unconditionally jump to its own position forever. A busy wait like this can be replaced with: For more information, see HLT (x86 instruction) . In low-level programming, busy-waits may actually be desirable. It may not be desirable or practical to implement interrupt-driven processing for every hardware device, particularly those that are seldom accessed. Sometimes it
70-423: A global integer i . The first thread uses busy-waiting to check for a change in the value of i : In a use case like this, one can consider using C11 's condition variables . Most operating systems and threading libraries provide a variety of system calls that will block the process on an event, such as lock acquisition, timer changes, I/O availability or signals . Using such calls generally produces
84-565: A hospitality business Nga La language , spoken in Burma (ISO 639-3: hlt ) Hurricane Liaison Team of the United States National Hurricane Center See also [ edit ] Halt (disambiguation) Topics referred to by the same term [REDACTED] This disambiguation page lists articles associated with the title HLT . If an internal link led you here, you may wish to change
98-419: A technique that was necessary on systems that lacked a method of waiting a specific length of time. Processor speeds vary greatly from computer to computer, especially as some processors are designed to dynamically adjust speed based on current workload. Consequently, spinning as a time-delay technique can produce inconsistent or even unpredictable results on different systems unless code is included to determine
112-495: 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 for sleeping and idling. In most processors, halting (instead of looping) also reduces the latency of the next interrupt. Since issuing the HLT instruction requires ring 0 access, it can only be run by privileged system software such as
126-446: Is sleeping or waiting, it will normally execute a HLT instruction to cut power usage until the next hardware interrupt. 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 used to generate an arbitrary time delay,
140-576: The HLT instruction, but it was not used by MS-DOS prior to 6.0 and was not specifically designed to reduce power consumption until the release of the Intel DX4 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 to implement
154-422: The kernel . 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 to decide whether other processes are runnable; if not. If every process
SECTION 10
#1732797551352168-399: The link to point directly to the intended article. Retrieved from " https://en.wikipedia.org/w/index.php?title=HLT&oldid=1141233066 " Category : Disambiguation pages Hidden categories: Short description is different from Wikidata All article disambiguation pages All disambiguation pages HLT (x86 instruction) Most operating systems execute
182-488: The simplest, most efficient, fair, and race -free result. A single call checks, informs the scheduler of the event it is waiting for, inserts a memory barrier where applicable, and may perform a requested I/O operation before returning. Other processes can use the CPU while the caller is blocked. The scheduler is given the information needed to implement priority inheritance or other mechanisms to avoid starvation . Busy-waiting itself can be made much less wasteful by using
196-542: The time a processor takes to execute a "do nothing" loop , or the looping code explicitly checks a real-time clock . In most cases spinning is considered an anti-pattern and should be avoided, as processor time that could be used to execute a different task is instead wasted on useless activity. Spinning can be a valid strategy in certain circumstances, most notably in the implementation of spinlocks within operating systems designed to run on SMP systems. The following C code examples illustrate two threads that share
#351648