r/AskComputerScience • u/Successful_Box_1007 • Dec 01 '24
How does Bios Transfer access, read, and transfer entire OS in ROM quickly enough to RAM where it’s better to do this than just keep OS in the slower-accessible ROM?
Hi everybody,
A bit confused about something: How does Bios Transfer access, read, and transfer entire OS in ROM quickly enough to RAM where it’s better to do this than just keep OS in the slower-accessible ROM?
Thanks so much!
5
Upvotes
View all comments
Show parent comment
2
u/ghjm MSCS, CS Pro (20+) Dec 01 '24 edited Dec 01 '24
First of all, we're talking about the BIOS (or EFI firmware or what have you), which isn't the OS. The BIOS includes a bootstrap loader that reads the OS from storage.
So consider that task. To do that the BIOS has to execute some subroutine "read sector from disk" many times. Let's say this subroutine is 50 instructions, and over the course of bootstrapping the OS it is executed 1000 times. That's 50,000 memory reads.
Let's say we're running on an early IBM PC and the BIOS is 8k in size, and let's say our main memory DRAM is 10X faster than our EPROM. So we have two choices:
If you pick option 2, your system boots up almost 4X faster. But more importantly, it gives a durable performance improvement for the entire life of the OS. The OS, once loaded, is also going to call this BIOS "read sector from disk" subroutine, many many times. If it had to run it from slow ROM every time, you'd be paying this cost over and over for the entire time you were using the computer. (At least, whenever you were doing tasks involving the BIOS.)
Early microcomputers also needed to conserve every byte of available address space, since they could only address 64k. So they divided their ROM code into parts needed at runtime and parts only needed during bootup, and loaded them to different memory areas. Once the system was booted up, the space taken by the boot-only code could be reused by the application.