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

Re: [MiNT] Freeing child's base page



Miro Kropacek wrote:

>     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

Yes, I think Vincent got it here :-) However, I'm not so sure if the
basepage and text/data/etc *always* is in one contiguous block. It's
possible to create just a basepage with Pexec, and set it to point to
the TEXT-segment of another process (threading). IIRC this technique is
used in some of Ozk's assembly-programs, like TextView! Mfreeing the
basepage in this case will only free the basepage itself.

> 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.

Are you sure about removing that assignment? In this particular case it
would be right, but what happens when the LDG TSR is used? If I
understand it correctly, the module loading/unloading is taken care of
by the TSR then. This could mean that assigning a NULL to this pointer
actually is needed. I'm only guessing here :-)

So perhaps the correct procedure would be to copy the pointer, set the
original to NULL, then Mfree using the copy.

>     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.

PE_NOSHARE? This is a Pexec-mode, right? I think Vincent means the
header-flag which indicates shared TEXT.

Jo Even