Maurice's Notes
Blog
Low Level Computing
Low Level Computing
  • Operating Systems
    • General Operating Systems
      • OS Structure
      • Main Memory
        • Basic Hardware
        • Address Binding
        • Memory Address Register
      • Booting
        • MBR (Master Boot Record)
        • Global Descriptor Table
      • Direct Memory Access (DMA)
        • DMA
      • Processes
        • Basics
        • Process Scheduling
    • Linux Operating System
      • Linker Scripts
      • Position Independent Code/Executable
      • Relocation
      • Understanding PLT and GOT
    • Windows Operating System
      • Page 1
    • Real-Time Embedded Systems
      • Real-Time Scheduling
        • Cyclic Executive
  • Computer Architecture
    • Architecture Fundamentals
      • Introduction
      • Cache Basics
      • Cache Memory
      • A Few CPU Formulas
    • RISC Architectures
      • ARM
        • ARM Design Philosophy
        • RISC Review
        • Exceptions, Interrupts, & Vector Table
        • ARM Pipelines
        • ARM Registers
        • ARM Branch Instructions
        • ARM CSPR (Instructions)
        • ARM Data Processing Instructions
        • Load/Store Instructions
        • Profiling Cycle Counter
        • Compiler Optimizations
      • RISCV
    • CISC Architectures
    • Cache Coherency
      • Basic Introduction
      • Memory Sequential Consistency
  • Exploits
    • Walkthrough: Return-to-Libc
    • Access Physical Memory
  • Compilers & Runtime Systems
    • Introduction
      • Programming Language Basics
      • Static Scope
    • Syntax Translation
      • Syntax Defined
      • Parsing
    • Algorithms
      • FIRST FOLLOW (Top-Down) Parsing
      • Building a Recursive Descent Parser
      • Construction: Regular Expression -> NFA
Powered by GitBook
On this page
  • Memory Protection
  • Base and Limit Registers

Was this helpful?

  1. Operating Systems
  2. General Operating Systems
  3. Main Memory

Basic Hardware

PreviousMain MemoryNextAddress Binding

Last updated 7 months ago

Was this helpful?

Main memory and registers belonging to each processing core, are the only general-purpose storage that the CPU can access directly.

  • Machine instructions can have memory addresses as an operand, but not disk addresses.

Remember that RISC systems are load/store, and do not directly access memory. Instead, content is loaded from a memory location, into a register.

  • Registers are the fastest storage in the memory hierarchy; CPU's can access register in one cycle. Some CPUs are capable of decoding instructions and performing operations at the rate of 1+ operations/clock tick.

Main Memory is accessed using a transaction bus, making it a slower access tier of the memory hierarchy compared the registers. CPUs may take many CPU cycles to complete a memory access.

  • CPU would have to stall the pipeline. [See , ]

  • Necessitates the use of . A multicore architecture design will typically include a private L1 and L2 Data cache (and L1 instruction cache if non-unified); each core would share an LLC (Last-level Cache), typically L3. [See ]

Memory Protection

Memory space must be protected. When a system first boots, it boots to read-mode, a 16-bit OS mode that provides no memory protection. Most bootloaders will attempt to switch to protected mode as soon as possible.

An Operating System must protect kernel space from user-space processes, as well as protecting a user-space process from other user processes. Since the operating system rarely intervenes between CPU and its memory accesses, the hardware must provide this protection.

Separate Per-process Memory

Each process should have it own address space for operation. This is necessary for concurrent execution on an operating system, and is a fundamental step in protecting user processes from one another.

Base and Limit Registers

Base and limit registers are used to define the range of legal addresses that a process may access. The base register hold the smallest legal physical address, while the limit register specifies the size of the range.

Note: Don't confuse this with base/limit shown in to learn more.

The base and limit register can only be set using a privileged instruction, inherently restricted use to the operating system (which runs in kernel space).

Any attempt by a user-space program to access kernel space memory, or another processes memory will result in a trap. The exception will subsequently be handled by the processor, co-processor, or programmable interrupt controller.

The Kernel Exception

The kernel, however, is permitted to access privileged memory space, as well as user memory space. This allows it to load and unload user programs.

  • Consider a context switch in a multiprocessing system. The kernel can store a processes state in main memory, freeing up registers for another process. (In some cases, a process is responsible for saving its own state).

Excellent Resources

  • Micoprocessor Design Wiki

A multithreaded core can switch from the stalled hardware thread to another hardware thread.

.

The is relevant to this post.

1
2
Cache
SRAM cache
Global Descriptor Table
Multi-core and multi-threading Blog post
page on cache