[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Freeing child's base page



 
You miss the fact that (basepage+text+data+bss+stack) is always a single contiguous memory block starting at the basepage. If you Mfree the basepage, you free the whole block starting from the basepage, including the global variables in the data and bss segment.
Vincent, this is it! This is the comment I was looking for! So if this is right, then my problem is solved because it's perfectly legal to delete the last line with NULL / whatever assignment and that's it.

So, if I understand it correctly, when Pexec() returns (using Pterm or Pterm0) :

1. all dynamic memory (using M[x]alloc) is returned back to OS, all opened files are closed
2. its text/data/bss segment is still intact, waiting for our Mfree() call (and this can be changed by using Pexec (6, ...) but don't want it of course)
3. static variables are in data segment, i.e. point 2 applies here, i.e. we can use it as long as basepage isn't free'd

Correct?
 
However, it seems that MiNT handle special executable flags to share the text segment among several process, but I never tried them as this is a very specific case.
You mean PE_NOSHARE mode? This is default off, i.e. child's memory is shared with parent, so no worries here.

--
MiKRO / Mystic Bytes
http://mikro.atari.org