operating-systems hardware

Definition

Program Status Word

The Program Status Word (PSW) is a critical hardware register that encapsulates the current state of the processor. it contains status information that defines the execution context of the currently running process and the operating mode of the CPU.

The PSW is an essential part of the process’s context, which must be saved in the PCB during a process switch to ensure execution can be resumed correctly.

Components

The specific bits in a PSW vary by architecture, but typically include:

  • Condition Codes (Flags): Bits set by arithmetic and logic instructions (e.g., Zero, Negative, oVerflow, Carry) used for conditional branching.
  • Interrupt Mask: Controls whether certain interrupts are enabled or disabled (masked).
  • Execution Mode: A bit (or bits) indicating whether the processor is currently in User Mode or Kernel Mode.
  • Stack Pointer (sometimes part of PSW): Pointers to the current execution stack.

Role in OS Control

When a Supervisor Call, Trap, or Interrupt occurs, the hardware automatically saves the current PSW and loads a new one (often pointing to the kernel’s entry point). This mechanism allows the OS to transition from user space to a protected kernel environment safely.