5 ms·
But then the questions are, why does it need to initialize? Why doesn't it start in an initialized state, what factors make it impossible to determine that init
by adsche 7y ago
But then the questions are, why does it need to initialize? Why doesn't it start in an initialized state, what factors make it impossible to determine that initialized state beforehand and storing it? How close can we get?
- silon42 7y agoThe fact that reboots happen mostly when software (kernels, system) is upgraded is part of it. It's simplest and most reliable to initialize the system from clean state (I've often had an idea it would be best to reinstall Windows+software for each reboot).
- adsche 7y agoYes, but do you have an idea why that is, why is it so much more reliable to initalize every time than to generate an initialized configuration and reuse that? Developer errors? Not enough testing?
- dannypgh 7y agoPart of it is hardware support- your machine's state isn't just in main ram and CPU registers, it's also in the state of every embedded microcontroller and onboard memory of every device on the machine. It's to limit the complexity of suspend/resume that a lot of OSes will do things like reinitialize all drivers (e.g. unload/load kernel modules) to try to get the whole system into a known state, but this takes time. Relatedly, hardware can be added (or enabled) between boots, so whatever conditional hardware initialization was done when booting may result in a state that's not quite accurate later. Furthermore, some of the state (e.g. anything involving system time) will always need to be modified after restore, and that's a state transiston that's less well tested (moving your clock forward hours or days may make a lot of software flake out).
- cesarb 7y ago> reboots happen mostly when software (kernels, system) is upgraded is part of it Only if you never turn your machine off. Don't you power off your desktop every day when leaving work?
- scarface74 7y agoAt most, I would expect most technical people put their desktops to sleep when they leave. Well really, I would expect most of us to have laptops where we just close the top and it just sleeps.
- nickpsecurity 7y agoThere was a hard drive on the market in the past for high-security use that had write-protect and an admin mode. Maybe a PIN or something to get to admin mode. Memory getting fuzzy on it. The normal usage would be read-only with you saving your data elsewhere or to a write-able partition that had nothing to do with read-only part for OS and apps. Go into admin mode to change those. Otherwise, your system is fresh every boot. People do it with VM's, too. I think you were aiming for something physical with no extra software. That was closest thing I could think to it.
- Fronzie 7y agoHardware has lots and lots of pieces of memory, not only block-ram, but also many registers. The needs to be initialized after power-off. As for the software: Hibernate is storing that initialized state.
- adsche 7y agoSo would it be impossible/expensive to provide storage for those registers/memory etc. that can survive power-off, and then copy the state from there upon power-on? How much time would something like that take compared to initialization?
- magicalhippo 7y agoAs an example, consider the PCIe bus controller. Say it had some non-volatile memory so that when it powers on, it just reads the bus configuration from the NVM instead of enumerating and initializing the devices on the bus. Lots of time saved. Well that wouldn't really work without the PCIe devices also storing the configuration in NVM. If I plug a x16 device into a x4-only slot (as is typical for the third PCIe x16 slot on motherboards that have it), the device needs to know it has to only use 4 lanes, not the full 16. Ok, so say the controller has some way to tell the devices to save their state, and when powering on they all read from NVM and can just go on talking with each other right away, no further initialization required. Yay! Except then you power off your machine, and swap that GPU for the new one you bought from your friend. Now the new GPU has the configuration from your friends motherboard, and your bus controller has no idea about this new card... so this is doomed to fail. Of course this could be worked around by querying the bus for the devices we expect to be there... except that's the initialization step we were trying to avoid in the first place...
- adsche 7y agoSure, that all makes sense, but why could it not do the initialization once (when something changes like you describe), save it, and reuse it next time? EDIT: Ah, sorry, you're saying the enumeration/scanning for changes is what takes most of the time?
- cesarb 7y agoAll that PCIe enumeration takes much less than a second, in my experience. The current boot on the machine I'm using to type this took only 2.3 seconds for the kernel part (source: systemd-analyze).
- msbarnett 7y agoEnumeration, yes. But then you need to load and initialize all of the drivers for the stuff you just enumerated.
- lazyjones 7y agoIt’s smart to optimize for the common case (no hardware changes) and dumb to slow it down significantly just for this flexibility. This can’t be a major factor, vendors aren’t that incompetent.
- codeflo 7y agoIt's not impossible, just increasingly expensive. Modern software practices tend move a lot of the things that used to be done at compile time to initialization time or runtime. A lot of modern tooling is built around that idea. You gain a lot programmer productivity in exchange for increased memory usage, startup time and battery drain. Is that worth it? The market seems to says yes. As much as people complain about the battery life of their devices, in aggregate, they prefer apps with even the slightest usability improvements over apps with great performance. In the battle of delivering more tiny little features, programmer productivity trumps all other concerns.
- adsche 7y agoAbsolutely! But couldn't this be moved from a productivity/time problem to a storage/packaging problem? I.e., do the initialization once and save its state until some major factors change? Storage seems to be quite inexpensive. Emacs does something like this (not saving state after first run but shipping with an initialized state that was generated before, I believe).
- gruez 7y ago>Why doesn't it start in an initialized state That's sort of how Windows quick startup works. It saves the kernel state after startup, and on next startup, it restores it (kind of like hibernating the system). Iirc emacs does something similar with its lisp runtime as well.
- adsche 7y agoYes, I was thinking of Emacs, too. I'm basically curious why the BIOS etc. couldn't run once, store the result of initialization and then resuse that on every boot until the configuration changes.
- Slartie 7y agoBecause how would it know that some little detail about some configuration has changed (maybe you moved a PCIe card from one slot to the other, a firmware of something was updated, or whatever)? It would have to scan everything, every startup...and that takes time... And because the BIOS isn't your only state-holder, anything with a controller on it inside your PC holds state, and that is basically everything today. Including external devices, like everything connected via USB (actually those have two controllers minimum, a USB controller which holds communication link state and a controller for the actual device function, like being a keyboard or mouse). It totals to hundreds of controllers, and it simply isn't feasible to standardize a way for this entire system to somehow store an overall consistent runtime state. That is why plan B is taken: just re-establish that state every time. We call this process "booting" or "initializing".
- icebraining 7y agoI'd say that's essentially what suspend-to-ram means. Booting means throwing that state away and rebuilding it.
- adsche 7y agoRight, or even just something like suspend-to-disk (or other storage) but for the pre-OS part of the boot (so that constant power isn't required). Why can this not work?
- colejohnson66 7y agoIsn’t that what “hibernate” is?
- CGamesPlay 7y agoI would say no because I can’t reuse that state: all implementations that I’ve used discard the hibernated state afterwards. If there was an OS that reused those saved snapshots then I would argue that it does count as “booting”. It would be even more interesting to do this on a per-application basis. Atom does something like this to cope with long startup times, for example.
- pmontra 7y agoWould the pre OS part of the boot process need less than all the available RAM? Hibernate (suspend to disk) used to be slow with spinning disks. Even with SSDs, if on a 6 Gb/s SATA bus hibernating my 32 GB laptop would take 32 GB * 8 / 6 = 42 seconds, probably more. And 42 s to resume. My laptop goes from power off to login and Gnome loaded in less than that time. Of course it takes much more to open all the programs I need. That's why I suspend to RAM. Push a button to suspend and less than 10 s to be working again. By the way, it takes extra seconds for the laptop to connect to the Wi-Fi access point or to the ethernet switch. IMHO it's not fully usable until then.