Class CPU

Class CPU

Placement in the overall structure

Module
machine
Base classes
None
Derived classes
None
Time of creation
Specification of Task 2
Files
cpu.h cpu.asm

Description

This class is an abstraction for the CPU. It currently allows enabling/disabling interrupts and halting the CPU.

Public methods

void enable_int ()
Allows the interrupt handling by executing the assembler instruction sti.

void disable_int ()
Prevents interrupt handling by executing the assembler instruction cli.

void idle ()
Puts the processor into the halt state, from which it is only awakened again by an interrupt. Internally, the interrupts are enabled with sti and the processor is stopped with hlt. Intel guarantees that the instruction sequence sti hlt is executed atomically.

void halt ()
Halts the processor. Internally the interrupts are disabled with cli and then the processor is halted with hlt. Since the halt state could only be left by an interrupt, it is thus guaranteed that the computer "stands still" until the next cold start. The program never returns from halt().