Omnimaga

Calculator Community => Discontinued => Major Community Projects => KnightOS => Topic started by: SirCmpwn on March 02, 2011, 10:16:38 pm

Title: Hibernation
Post by: SirCmpwn on March 02, 2011, 10:16:38 pm
So here's what I think I can do with KOS to hibernate:
1. User requests hibernation
2. The kernel takes control, shuts down multithreading and kills interrupts.  It is now the only running process.  Because it halts interrupts, all threads are suspended in their current state.
3. The kernel creates a file: /tmp/hibernation.data (filesystem is in ROM)
4. In this file, it dumps all RAM (which contains executing programs, each program's stack, the thread table, allocated memory... everything that makes KOS tick)
5. Then, it turns off the calculator.
*some time later
6. The user turns on the calculator.
7. During boot, the kernel sees that /tmp/hibernation.data exists, and loads the contents into RAM (remember that at this point, multithreading has not been initialized, or memory management)
8. The kernel deletes /tmp/hibernation.data and skips most of the initialization process.
9. Simply enable interrupts, and you're right back to the state you left it off from!
Title: Re: Hibernation
Post by: DJ Omnimaga on March 03, 2011, 11:37:32 pm
Seems good to me. SOmetimes it's good to not have to wait 2 minutes for an OS to boot everytime you want to use your laptop or computer. Not that it would take this long on a calc, unless you're TI, but it would be good. I like how newer Casio calcs do that.
Title: Re: Hibernation
Post by: SirCmpwn on March 03, 2011, 11:38:36 pm
Yeah, it won't take long either way.  And sleeping the calc would be instantaneous.
Title: Re: Hibernation
Post by: DJ Omnimaga on March 03, 2011, 11:42:13 pm
Sleeping a calc? ???

j/k I know what you mean. :P (although this reminded me so much of "Please SD-Card insert" :P)
Title: Re: Hibernation
Post by: SirCmpwn on March 03, 2011, 11:43:13 pm
A winner is you.
Title: Re: Hibernation
Post by: Eeems on March 03, 2011, 11:48:18 pm
One question, are you going to set aside the necessary space required for the temporary file? That seems like a lot of space.
Title: Re: Hibernation
Post by: SirCmpwn on March 04, 2011, 12:34:13 am
I was thinking of using the swap sector.
Title: Re: Hibernation
Post by: DJ Omnimaga on March 04, 2011, 12:47:12 am
Wasn't the swap sector used by OS 2.55MP, though? ???
Title: Re: Hibernation
Post by: SirCmpwn on March 04, 2011, 12:49:48 am
No, every OS needs a swap sector to modify flash, a sector of ROM that isn't used for anything.
Title: Re: Hibernation
Post by: DJ Omnimaga on March 04, 2011, 12:51:15 am
Oh wait what was I thinking? We're talking about another OS here lol, not a shell. X.x Disregard my question
Title: Re: Hibernation
Post by: Eeems on March 04, 2011, 01:43:49 pm
Did not know about the swap x.x
Makes sense now :)
Sounds like a perfect use of it :)
Title: Re: Hibernation
Post by: ztrumpet on March 06, 2011, 02:10:52 pm
Sounds like a great idea.  KOS is going to be great. :D
Title: Re: Hibernation
Post by: SirCmpwn on March 06, 2011, 04:20:33 pm
I still haven't picked a swap sector x.x I need to do that today.
Title: Re: Hibernation
Post by: jnesselr on March 06, 2011, 04:45:22 pm
Sounds like a great idea.  KOS is going to be great. :D
I didn't think you could pick a swap sector.  In which case, what does TI use?
Title: Re: Hibernation
Post by: SirCmpwn on March 06, 2011, 04:54:24 pm
I have no idea, but I don't really care what TI's doing.
Title: Re: Hibernation
Post by: Deep Toaster on March 06, 2011, 05:17:43 pm
I have no idea, but I don't really care what TI's doing.

Well, maybe you could pick a different one, to spread out the flash wear a bit.
Title: Re: Hibernation
Post by: SirCmpwn on March 06, 2011, 05:18:32 pm
I think I'll put it right before the privileged sector.  It's a pity that it isn't better organized.