Programming: Operating Systems: Difference between revisions
No edit summary |
|||
Line 143: | Line 143: | ||
</blockquote><!-- Bootstrap --> | </blockquote><!-- Bootstrap --> | ||
</blockquote><!-- Startup --> | </blockquote><!-- Startup --> | ||
= Kernel = | |||
<blockquote> | |||
== Kernel Event Queue == | |||
<blockquote> | |||
See [[kernel event queue]]. | |||
</blockquote><!-- Kernel Event Queue --> | |||
</blockquote><!-- Kernel --> |
Latest revision as of 13:42, 18 December 2022
Tutorials
rust OS tutorials https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials
Component Overview
System Bus/Switch
Middleman between CPU and all system devices.
Brokers communication between devices and CPU, or with each other.Devices
Communication
Interrupt Signals
wikipedia https://en.wikipedia.org/wiki/Interrupt Operating System /\ | | | | \/ Device Driver (software) /\ | | | (via Interrupts) | | | | | \/ Device Controller (hardware)For example, a keypress.
- device controller loads info into it's registers describing action to take (ex: read a char form keybard)
- device controller populates a local buffer with data, and informs driver that data is available to be read
- driver passes info to OS
TODO:
who initiates this? hardware? os? either?
Flow:
- Interrupts are signals sent (normally) to the system bus.
- When received, CPU stops current task, caches any state
- Interrupt signal number is then looked up in interrupt vector (array mapping signals to their routines)
- routine is processed
- CPU restores state, continues previous task
Terminology:
- device controller raises interrupt
- CPU catches interrupt
- CPU dispatches to interrupt handler
- CPU clears interrupt
Notes:
- Modern CPUs prioritize interrupts using 2x interrupt-wires to the cpu (maskable, and critical/non-maskable)
- Computers often have more devices than interrupt vector can hold, so entries are usually pointers to other datastructures that can lookup interrupt destination
NOTE:
Different than unix signals, which behave similarly but are processed by the operating system, and affect the processing of a processDirect Memory Access (DMA)
Interrupt-driven events is innappropriate for larger/slower non-volatile-storage.
DMA uses a single interrupt-per-block (size determined by filesystem) instead of per bit.
Aside from that, I/O communicates directly between storage device, and RAM.Memory
Some types:
- RAM (random access memory) is volatile (non-persistent) memory (generall DRAM)
- EEPROM (electronically eraseable programmable read only memory) is persistent, but slow. infrequently written to. It is responsible for loading your bootloader, which bootstraps your boot manager, and eventually operating system.
- HDD (hard disk drive)
- NVM (non volatile memory) flash
Structure:
- Memory is composed of an addressed array of bytes (8-bits)
- Two operations are used on memory
* load copies data from itself into CPU register * store saves data to itself
CPU
- CPUs have registers of a specific word-size. A 64-bit processor uses a word-size of 8-bytes (8*8bits==64)
- Devices may have their own microprocessors (ex: keyboards have a microprocessor that converts keypresses into codes sent to the actual CPU).
+------------------------------+ | Processor | |+-------------+ +------------+| || Core-1 | | Core-2 || || registers| | registers|| || L1 Cache | | L1 Cache || |+-------------+ +------------+| | | | | | +-----+------+ | | | | | \/ | | +----------+ | | | L2 Cache | | | +----------+ | +------------------------------+ | \/ +------------------------------+ | Memory | +------------------------------+
Startup
Bootstrap
Your motherboard's firmware/BIOS is installed onto EEPROM. It uses a system like efi or bios to find and load your operating system.
- BIOS (old) loaded OS bootloader from first sector on disk
- EFI (new) finds bootloaders on disks, using an entire dedicated partition rather than just first sector
Kernel
Kernel Event Queue
See kernel event queue.