I'm taking a uni course on electrical engineering and my textbook says that the CMOS battery used to last between 2 and 10 years. Since preserving BIOS settings seems quite important to me, I was wondering what happened when the CMOS battery ran out. Were the settings lost? Did you have to reset them when you had system power? Or did you have to change the CMOS battery?
PCs (and many laptops/netbooks) have a backup battery to preserve any volatile settings, and to keep the clock (RTC) ticking over so the computer knows the time - if you have ever wondered how you computer still knows what time it is even if you unplug it from the mains, the battery powered RTC is how. This battery is in most cases only used when there is no mains power.
In terms of what happens, it depends partly on the BIOS.
In older BIOS's and probably many new ones two, the settings would basically delete on power loss (they are in volatile memory). In fact there is a jumper which disconnects the battery and standby power to allow you to reset the BIOS settings.
Some modern BIOS's store the data in non-volatile memory, so all the battery dying would do is clear the clock.
Note that all of the above assumes there is no mains power. If the power is on (Either when the PSU is powered on, or so long as there is mains to drive the standby rail), the BIOS will remain powered and losing the battery would do nothing.
If your computer is always plugged in to the mains, you may never notice the battery is dead. But as soon as you have a power cut or unplug, the time goes away, suddenly you are back in the 90's or whatever preset date/time is hardcoded into the BIOS.
Once dead, you can usually just replace it with a new coin cell, restore the time settings any non-default BIOS settings (if that is volatile), and you're good to go for another few years. If you replace it while the PSU is supplying standby power and before the battery is completely dead, you may even not have to change any settings.