Wednesday, June 01, 2005

Why can't I turn off my computer?

It has always bugged me that it takes nearly a minute for my PC to shut down. Why can't I simply power the machine off like I would with any other appliance in the home? On Windows, the main culprit I've found is that the OS decides it needs to save a bunch of user settings and flush all kinds of things to the file system only when I actually decide to shut down the machine. My question: why on earth isn't all that stuff already flushed to disk, given that my PC is completely idle most of the time and was, in fact, doing nothing at all for five full minutes before I decided to shut it down!? This practically cries out for smart, adaptive programs that can exploit system load information.

The second reason I've found for slow shutdowns is that the OS sends an explicit kill signal to all the processes, giving them a chance to perform a graceful shutdown. But in this modern era of complex, P2P applications running on unreliable networks, it should be possible to write most of these processes in a way that they can often be terminated with no adverse consequences (especially given that they should not be very write-intensive).

For example, the only time I need my browser to die gracefully is if it is saving some file to disk for me. But, most of the time, it is simply downloading something off the web, loading data in memory or storing it in temp space; I should be able to happily kill the browser during these times. Perhaps it would help if we partitioned our storage into two: a regular file system where consistency checks are performed, and a scratch space where temporary files are written and consistency checks can be skipped. Can anyone with more expertise comment?


Blogger Harsha V. Madhyastha said...

The OS does need to send a kill signal to many processes (for example, device drivers) that have access to data structures within the kernel, so as to ensure that its data structures are in a consistent state when it does finally reboot. Hibernation tries to get around this delay by just dumping memory onto disk, but frankly I don't know whether this would work when you need to reboot after loading a new driver.

(Great to find another person interested in cricket, basketball, baseball, and the lot!)

(Football sucks though!)

6/02/2005 12:38 AM  
Blogger Prasanna said...

I guess my point was that most processes don't need to have "uncommitted" transaction state in memory, at least most of the time. It would be nice to have the kernel keep track of exactly which processes are currently messing with critical state (via a locking mechanism) and send only these processes the kill signal. The rest can just be ignored.

6/02/2005 12:05 PM  

Post a Comment

<< Home