Linked by David Adams on Sat 17th May 2008 03:39 UTC, submitted by IdaAshley
General Unix Ever wonder what makes a computer tick or how a UNIX server does what it does? Discover what happens when you push the power button on your computer. This article discusses the different boot types, managing the AIX bootlist and the AIX boot sequence. After reading this article, you will better understand what exactly happens when your server starts.
Thread beginning with comment 314647
To read all comments associated with this story, please click here.
Comment by Kroc
by Kroc on Sat 17th May 2008 18:17 UTC
Kroc
Member since:
2005-11-10

What I'd like to know is what an OS does when it shuts down??
Why does it even touch the disk at all? I really don't understand why it takes so long. A Kill signal should be sent to all processes, and then the power cut. What is the hard disk needed for? If there's stuff still be saved, why wasn't it saved when it was changed to begin with (like preferences &c.)?

Whatever happened to the Amiga way of shutting down? Why isn't that possible now ;)

RE: Comment by Kroc
by sonic2000gr on Sat 17th May 2008 19:34 in reply to "Comment by Kroc"
sonic2000gr Member since:
2007-05-20

What I'd like to know is what an OS does when it shuts down??
Why does it even touch the disk at all?


An (oversimplified) explanation is this:

Most of the processes you mention maintain data files on the filesystem, constantly reading and writing to it. An obvious example is e.g. a database system. The OS itself does not immediately commit all writes to disk: it prefers to keep some of them in memory and flush them to disk at the best opportunity (i.e. when load is low etc). This is necessary, since disk writes are costly (hard disks may be very fast these days, but they are still a lot slower than main memory). Other things to consider are: Processes which are swapped out to disk, files that are cached and so on. At any point in time, the filesystem has open files, with data either waiting in memory to be written or being currently written. When an application knows it will access the file again soon, it will not close and reopen it (this is costly as well).
When you shutdown, every process must be stopped, and all the data has to be actually written on the disk platters. Only then is the filesystem consistent and ready to be unmounted. Depending on how many apps are running and the amount of writes still pending, this may take some time.
Having said that, I rarely turn off my Linux/BSD systems, so this does not affect me ;)

Edited 2008-05-17 19:36 UTC

Reply Parent Bookmark Score: 2

RE[2]: Comment by Kroc
by Kroc on Sat 17th May 2008 20:12 in reply to "RE: Comment by Kroc"
Kroc Member since:
2005-11-10

In that case Vista must decide to rewrite the entire hard disk just for good luck, with the amount of churning and how long it takes. I've seen Vista laptops take three to four whole minutes to shut down! That isn't dumping buffers, that's earnestly trying to hit the MTBF

Reply Parent Bookmark Score: 6

RE[2]: Comment by Kroc
by Doc Pain on Sun 18th May 2008 10:12 in reply to "RE: Comment by Kroc"
Doc Pain Member since:
2006-10-08

Regarding the question

What I'd like to know is what an OS does when it shuts down??
Why does it even touch the disk at all?


you gave a good explaination. I'd like to add the following:

Most users coming from a PC background do not see that UNIX is meant as a multi-user multi-process operating system. So it may be possible that many users are working on the same machine when it shuts down. The OS usually gives shutdown warnings, giving users the time to finish their work. Then, specifig signals are used to make the running applications do their own "shutdown stuff", e. g. saving unsaved files to disk so they don't get lost even if the user forgot to save them. After this, the applications are requested to terminate theirselves.

As you mentioned, data usually is written asynchronously. So the OS usually waits some time until all buffers are flushed at shutdown.

Having said that, I rarely turn off my Linux/BSD systems, so this does not affect me ;)


Understandable. :-)

Reply Parent Bookmark Score: 3