Shutdown..

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

I guess the fundamental problem is that apps and services are designed on the basis that they will be started, used, and closed. If all apps and services where written not to expect a clean shutdown, then not only could we do shutdown just by telling the mobo to turn-off the power, but we could also expect the computer to not have any trouble restarting after power-failure.

It's possible to do this without losing any data too. Just make sure everything in the system is transactional. EROS I guess had such persistence to the point where you could literally hit the hard switch, and expect all your programs to come up in the exact same state when the system got power again. You might lose a couple of seconds, but the state would always be consistent in any case.

But ofcourse writing such a system is not quite trivial, especially if you still want some sort of performance out of it (that is, we don't accept a solution such as "stop everything once a second, and save all state to disk before continuing").
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

jal wrote: there's no excuse for a program to even have a "save" option. Of course everything should be saved automatically!
I disagree. There are many times that I create some total quickie text page -- just to email, or post on LJ, or to post a faked-up code sample here, or something. I definitely *do not* want any of that saved, taking up precious space on my HD! I want a checkbox on my editor screen, to turn autosave on or off, per document.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Hang on a second. We're all worrying about shutdown times here. Why do they matter again? The user is just going to walk away from their PC and go and do something else. It's startup we should be worried about, isn't it?
I have to wait for shutdown to complete before I can turn off mains so that all those USB devices don't keep lurking power (like my LED-decorated mouse - It lights the entire room during the night)
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Yayyak wrote:Hang on a second. We're all worrying about shutdown times here. Why do they matter again? The user is just going to walk away from their PC and go and do something else.
Not entirely. For example, my computer and its peripherals (screen, printer, router) are connected to a power distributor with a switch. After the computer has shut down, I switch that switch to off, so all peripherals will go off as well (I don't like to have everything in sstandby mode all the time).


JAL
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

bewing wrote:I disagree. There are many times that I create some total quickie text page -- just to email, or post on LJ, or to post a faked-up code sample here, or something. I definitely *do not* want any of that saved, taking up precious space on my HD! I want a checkbox on my editor screen, to turn autosave on or off, per document.
Yes, I do that also, but an average user doesn't care. In fact, you could just by default open your 'scratch pad' (which is auto-saved like any other file), and if you like, you can delete text you no longer need.


JAL
com1
Member
Member
Posts: 105
Joined: Sat Apr 28, 2007 11:57 am
Location: TN

i would assume

Post by com1 »

i would assume that boot up takes a long time due to the lengendary true 'plug and play' since alot of the time hardware is recognized at boot up, the OS must put everything in place to use that hardware, thus concluding the long boot up. if there were a simple program to run after boot up that recognized and configured new hardware, boot up would probably be faster.
oh microsoft, microsoft, what souls you have dismayed
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

bewing wrote: I disagree. There are many times that I create some total quickie text page -- just to email, or post on LJ, or to post a faked-up code sample here, or something. I definitely *do not* want any of that saved, taking up precious space on my HD! I want a checkbox on my editor screen, to turn autosave on or off, per document.
That's totally nonsensical. It's just like paper documents then. Saving a paper document doesn't necessarily mean xeroxing it into a map, then throwing the original away (which is basicly what most apps nowadays do), saving a paper document consists of not throwing it into a recycling bin or shredder, simply leaving it around when you put your pen down.

Besides, this is widely implemented already in all kinds of portable devices like PDAs, and after you get used to it, it's really the most natural thing: you'll never lose anything just by closing an application or even turning off the power. If you don't want to keep something, just delete it. Delete is almost invariably found in a menu (if not, at least it should be). When you delete it, if you don't have anything else open (and there is no better view to display) you'd typically get a new document instead, so it's no more work than simply hitting "new" instead of "delete" in the menu.

Besides, free HD space is wasted HD space anyway, so until you manage to fill it up, it doesn't matter. Plus if you wrote 10kB of random text (which is quite a few random forum posts) every single day, for 3 years, you'd used a (huge) 10MB of HD space. That's like 6-8 minutes of decent quality MP3 audio? Most of us are measuring HD space in tens (some of us hundreds) of gigabytes nowadays. Even portable devices have hundreds of megabytes of memory (1 or 2 gigs isn't exactly rare either) and on PC most of us wouldn't care if we produces a megabyte of useless crap each day. I mean, after 3 years, that's just 1 gigabyte.

I've been getting a new HD (usually new PC as well) every 3 years now, since I had something like 486DX2/66, and after I got a 4gigabyte disk (after something like 850MB) I've never really had a disk fill. I was gonna say I've now had the same disk for longer, but forgot I bought this laptop.. oh well. My previous desktop (which I still use for certain things) has a 160GB disk. 100GB of that isn't even partitioned. And there's a Windows and a Linux system on the other 60GB.

Oh and you guess what's taking the space on these systems? No it's not text documents. It's easy to fill a large drive with tons of media (audio or video) but is a single gigabyte (as funny as it sounds) gonna save you? That's like a single movie, or 15 CD rips as MP3.. which reminds me I should probably uninstall WoW now that I haven't started it in half a year, for it's taking like 7GB+ HD space.. but I'm not going to bother, because honestly, it's just waste of time.. :)

Oh, and mm.. looking at local prices (just a few random examples)

Hitachi Deskstar 7K1000 750GB - 189.90 €
Hitachi Deskstar 7K1000 1TB - 276.90 €
Seagate Barracuda 7200.10 750GB - 183.90 €
Seagate Barracuda 7200.11 1 TB - 264.90 €

Ok, I wouldn't say a couple of hundred euro isn't money, but honestly, if you can fill harddrives faster than you can afford more space, you're almost certainly doing something illegal. :)
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

It's not MBs that are precious. It's directory entries, cache memory that directory entries fill up, and allocation table slots/inodes. They are far more finite than MBs. And your machine's performance does depend on keeping those resources free. Fill your disk 98% full, and see how fast your system runs. Equating free resources with "wasted resources" is simpleminded. Also, of course, most filesystems will get fragmented by constant rewriting of tiny, variable-sized files. Filesystem search efficiency (of course) will also decrease right along with the number of worthless backup copies of crap that get saved automatically.

Maybe it's just me, but I really hate it when the amount of free disk space I have trickles away, day by day, when I haven't been saving anything, and I can't find out where it's disappearing to.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

bewing wrote:It's not MBs that are precious. It's directory entries, cache memory that directory entries fill up, and allocation table slots/inodes. They are far more finite than MBs. And your machine's performance does depend on keeping those resources free. Fill your disk 98% full, and see how fast your system runs. Equating free resources with "wasted resources" is simpleminded. Also, of course, most filesystems will get fragmented by constant rewriting of tiny, variable-sized files. Filesystem search efficiency (of course) will also decrease right along with the number of worthless backup copies of crap that get saved automatically.

Maybe it's just me, but I really hate it when the amount of free disk space I have trickles away, day by day, when I haven't been saving anything, and I can't find out where it's disappearing to.
If 1 GB of big files use up less space the 1GB of several small files, then why not place all your not-so-often used small files in one huge archive?
My OS is Perception.
User avatar
inflater
Member
Member
Posts: 1309
Joined: Thu Sep 28, 2006 10:32 am
Location: Slovakia
Contact:

Post by inflater »

In my OS it's easy and fast. If you want to shut down, you just type the command, the processor will go in real mode, will write "Its safe to turn off your PC now, or press ENTER to reboot", and tries to shut down system using legacy APM services. If BIOS doesn't support them, the user is left with a screen telling him to turn off, or reset. FAT doesn't need to be specially unmounted or such. :P

I'm planning (in future versions of PortixOS) a GUI too, single-tasking Windows-like GUI with skin support. Yeah, single tasking... based on the idea:

You are presented with a graphical shell, that contains e.g. - main menu, where you can choose to set system settings, set system time, etc. This is all in one big executable, say KRNL486.BIN, so "partial multitasking" is possible (e.g. switching between windows, because they aren't real applications). Or for example, you would run a CD player, and when you would close the CD player window, you can leave the CD-ROM playing (but that's not multitasking at all, that's the drive option).

If user selects a program, the KRNL486.BIN app will clear the screen in one color for example, and it will create a tray bar with text "Press CTRL+ALT+DEL to terminate this application". Then it will give control to the user application itself, that will draw the applications window and function. That tray bar will be still visible. If the application will freeze, or make a exception, KRNL486.BIN (loaded in RAM) will return back control to itself regarding what happened. The same thing happens when user will press the key combo (the timer checks if the keys were pressed).

Simple, eh? :) No more BSOD, no hung applications, simplicity, no multitasking. :shock: Or at least user doesn't know that the system can't *really* multitask. :lol:

Regards
inflater
My web site: http://inflater.wz.cz (Slovak)
Derrick operating system: http://derrick.xf.cz (Slovak and English :P)
User avatar
JAAman
Member
Member
Posts: 879
Joined: Wed Oct 27, 2004 11:00 pm
Location: WA

Post by JAAman »

No more BSOD
really? so what does your kernel do if the HDD suddenly stops working, taking your page file with it... (the only time i have ever gotten a BSOD under win95)
no multitasking.
technically, you are multitasking -- anytime you are doing more than one thing at a time you are multi-tasking, plus, your users will either only be simple-minded idiot=users, or will loudly demand real multi-tasking
User avatar
mystran
Member
Member
Posts: 670
Joined: Thu Mar 08, 2007 11:08 am

Post by mystran »

I'd throw a wild guess that the most common reasons for BSOD under modern NT series Windows kernels are:

1: bad drivers
2: even worse drivers
3: memory chips not working properly
4: PSU not working reliably
5: CPU overheating

The order might be a bit different, but you get the point.

The drivers problem you can solve if you don't let 3rd party drivers into the kernel. The other problems are a bit harder.

edit:

CPU overheating is probably easiest: if the MOBO provides sensors, monitor the CPU temp, and if it ever goes above something you think is too much, then run idle loop until it cools down. If it doesn't cooldown, then you're screwed anyway, and you can just as well, tell the user to fix it and shut down the system.

The PSU trouble is probably the second easiest: if the MOBO again provides sensors, check that the voltages stay high enough and stable. If you get fast transients, the sensors might not give you those, but at least if the voltages start going low with more load in the system, you can again tell the user to fix it. In the mean while you could try to run less devices at the same time, or set some of them (like 'mm.. GPU?) to powersaving mode or something.

Finally... hmmh.. faulty memory chips? Yeah, get ECC memory. No serious, Vista actually does attempt to notice when you get strange failures, and asks to test your memory next time you boot. That's a step into the right direction. No idea if it monitors CPU temp or PSU voltages as well. Wouldn't be surprised if it did.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Post by Brendan »

Hi,

Quick note before I get some sleep...
mystran wrote:CPU overheating is probably easiest
For most CPUs (Pentium III and later?), the CPU has it's own automatic thermal throttling - if it gets too hot it'll drop it's effective frequency to whatever the BIOS configured (probably 12.5% or 25% of normal). If that's not enough to keep the CPU cool (a faulty CPU fan?) then the CPU will do a thermal shutdown (basically, it just locks up and does nothing AFAIK). Newer CPUs have additional stuff (e.g. software controlled thermal throttling and digital temperature sensors).

In any case, (for Pentium III and later) CPU overheating shouldn't cause erratic behaviour - you get slow performance instead (or complete lockup).

BTW the single most common reason for kernel crashes in Windows XP (according to Microsoft, and I actually do believe them) is device drivers. The companies that write the device drivers are typically hardware manufacturers (who's main business is not programming) and they're messing about inside the kernel at CPL=0, usually without the benefit of independant "peer review". It's a disaster waiting to happen... ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
madeofstaples
Member
Member
Posts: 204
Joined: Thu Apr 12, 2007 8:15 am
Location: Michigan

Post by madeofstaples »

I've just been skimming over this thread and I have to say you guys have a lot of interesting ideas.

I don't think anyone brought this up, and maybe it's not that big of an issue, but...

if an OS implemented such a design where it wrote any modified data to the hard drive as soon as possible in case of a shut down request... wouldn't that severely shorten the life of the hard drive, especially laptop hard drives?
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

madeofstaples wrote:if an OS implemented such a design where it wrote any modified data to the hard drive as soon as possible in case of a shut down request... wouldn't that severely shorten the life of the hard drive, especially laptop hard drives?
Why? And why especially on laptop hard drives? You might have a point for flash drives, but still, in general all modified data needs to get written, whether automatically or by the user.


JAL
Post Reply