[<Simon Wood>]
Firstly is Swapping a 'Must Have'?
For an embedded system without read/writable mass storage it serves no
purpose.
I hope that it is an option extra....
> Swapping under ELKS is going to have to have a fundamentally different
> approach from Linux. Linux runs on a protected mode architecture with full
> memory management which means that all memory adressing is virtual, and if
> a page of RAM is accessed which does not currently exist in real memory,
> to process is stopped and the page is copied in from disk. We cannot do
> this in ELKS as there is no memory protection. All we can do is swap out
> entire processes if they are not currently running. This can be done in
> two
> ways, as each process has two blocks of memory allocated. Firstly the code
> segment can be deallocated, but does not need to be swapped out as it can
> be re-fetched from disk at any time from the executable file. The code
> segment is totally unchanged at runtime. This feature is already exploited
> because we have the ability to run two or more copies of the same binary
> with only one code segment allocated. (See the code in fs/exec.c that
> loads
> the code segment for details.
[<Simon Wood>]
obiviously you will need some form of locking (to prevent executable code
changing) whilst a task is running, and some for of tracking of who trying
to use it and were the code segments are.
> The second possibility is to add the feature of saving the data segments
> of processes to disk. You could do this the conventional way by having a
> partition, but there are other options. One is to create an inode on the
> root partition which does not existas a real file, but in which blocks can
> be allocated and used to store process images. Another ELKS feature you
> may wish to exploit is that you do not need to save the whole data
> segment.
>
> The layou of the data segment is as below:-
>
>
> Address:- 0x0 t_endbrk t_endstack t_begstack
> _______________________________________________________
> | | | | | |
> | data | bss | heap | | stack |
> | | | | | |
> |________|_______|________|____________|______________|
>
>
> The unlabelled section in the middle is not used, and is frequently a
> large
> proportion of the data segment.
[<Simon Wood>]
Well that depends on you compilier and compilier options. The people who
write the applications should set these to sensible values.
You could quite happy copy the data segment and miss out the middle (not
used at this precise moment of time) section providing the code was doing
anything wierd.....and who knows what some code does????