How are applications and data accessed by the CPU from RAM

前端 未结 4 1654
借酒劲吻你
借酒劲吻你 2021-01-24 23:39

I am having a bit of trouble understanding how applications and data are accessed by the CPU from RAM after the application has been loaded into RAM and a file opened (thus data

4条回答
  •  一整个雨季
    2021-01-25 00:27

    It is confusing indeed. Let me try to explain.

    CPU and RAM

    The CPU is hardwired to the RAM via the 'motherboard', and they work together. The CPU can perform many instructions, but it has to be told what to do by instructions in RAM. The CPU is basically in a loop: all it does it fetch the next instruction from RAM and execute it, over and over.

    So how does this RAM get filled with instructions?

    BIOS (basic input/output system)

    When the computer first boots up, a portion of RAM is filled with data from a chip on the motherboard (the BIOS chip), and the CPU is turned on and starts processing. These are the factory settings.

    The data from the BIOS chip that is copied to RAM consists of a library of instructions to access hardware devices (hard disks, CD/ROM, USB storage, network cards etc.), and a program using that library to load what is called the bootsector, the first sector on the boot device, into RAM, and transfer control to it (with a jump instruction).

    BOOTLOADER

    The bootsector data that the BIOS program loaded from the boot device is very small - only 440 bytes - but with the help of the BIOS library, this is enough to be able to load more sectors and execute these. The bootsector and the data it loads is called the bootloader, which is in charge of loading the Operating System.

    In effect, the bootloader is a more dynamic version of the BIOS: the BIOS program resides in flash memory, whereas the bootloader resides on hard disks, USB sticks, SSD drives etc., and thus can be larger and more complex.

    OPERATING SYSTEM

    In it's turn, The operating system (OS) is simply a more advanced version of the bootloader, as it can load and run multiple programs from multiple locations at the same time.

    --

    The BIOS knows about drives. The Bootloader knows about drives and partitions. The OS knows about drives, partitions, and file systems.

提交回复
热议问题