Hi,
This is probably off-topic (I apologize), but hopefully the concept I'm about to explain is enough to justify it..
Candy wrote:
just for a concept for OSes, as fits the forum:
An operating system should use the system during idle periods so that it can respond quickest when it is in use.
So, if you're reading what's on screen, the OS can do what it wants to do, but if you're installing an app it should not be required to use some of your, at that point, valuable cpu cycles for background tasks.
If you want all pages to be zeroed (yes you do), you can either run it in the background or in the foreground (in this context, that means at request). In the background would make all pages zeroed when you need them without other work, and in the foreground would make all pages being zeroed when you need them. The first moves the work to the background section of time, which is the best to use for it.
IMHO everything that the CPU does can be classified into 3 distinct types of work: reacting, pre-processing and waiting.
Reacting is where something happens that causes the CPU to do work straight away (e.g. the user presses a key, the hard drive completes a transfer, the ethernet card says a packet has arrived). Pre-processing is where the CPU is doing work that doesn't have to be done straight away, but will hopefully improve performance later on. Waiting is where the CPU can't find anything to do (e.g. it's executing the HLT instruction, or it's sent to sleep, or it's polling hardware).
Now a "perfect" OS would spent 100% of it's time pre-processing! Think about this for a bit...
Imagine that you've turned your computer on, you're waiting for it to finish booting and the doorbell rings. It's a good friend with some snacks and a movie that you've been dying to see for ages (Lord of the Rings! Holy cow
). You grab some drinks, some snacks and settle down to watch the movie, completely forgetting that you've left your computer running.
When you finally get back to your computer it's pre-loaded every single application that you might want to use, and they're all running in the background just waiting for you to "start" one. You click on your web browser and it's up on your screen
instantly because the video data was already pre-processed ready to blast into the video card. Then you decide to send the browser to this forum and it's on your screen
instantly because the computer knows you come here often and it's already downloaded everything and pre-processed the video for it. You decide to compile your OS while your reading some interesting messages on the forum, so you run 'make' and guess what? It's completed
instantly because the OS already compiled it and had the new/modified data stored on disk already - all the OS had to do was to commit the directory entries into the cache (in RAM). Then you decide to scan your 120 GB hard drive for bad sectors - you guessed it already, the scandisk utility skips everything that's been checked recently and completes
instantly.
Sound a bit too hard to believe? Well I did say a "perfect" OS, and we all know nothing is perfect...
Most OS's actually spend negligable amounts of time pre-processing. With the above scenario windows would spend a few hours doing absolutely nothing at all, then when you start using the computer it'd go flat out trying to get things done quickly (and Linux isn't any better). After all that's why you paid so many $$$ for that fast new CPU isn't it?
Now consider me sitting here typing. What's my CPU doing? I'll tell you - it's spending 99% of it's time doing absolutely nothing, waiting for me to press a key. Why isn't it using the time between keypresses to scan my disks for bad sectors (it's been a while), or running a spell checker in the background? I guess I'll have to sit here and wait a little while when I tell it to spell check in a few minutes. Why isn't it pre-loading Quake for me - it should know there's at least a 50% chance I'll want it ready when I'm finished typing.
Like I said, nothing is perfect, but an OS can do no pre-processing at all or it can pre-process as much as possible. My OS will be pre-processing as much as possible...
Cheers,
Brendan