Mailing List Archive

Support open source code!


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

Re: tlug: Overwriting running executable



>>>>> "Neil" == Neil Booth <NeilB@example.com> writes:

    Neil> Stephen J. Turnbull wrote:
    >> No, if they leave memory they end up in swap.  Only if you
    >> demand-load DLLs (eg, the GNU Emacs in Debian-JP does this)
    >> will any executable code be left on disk.  Unix systems don't
    >> do overlays and silliness like that, they use virtual memory.
    >> However ...

    Neil> I thought just dirty pages ended up in swap. An executable
    Neil> image isn't writable, so doesn't tend to get swapped. Or is
    Neil> my example a special situation, and the memory is flagged as
    Neil> swappable?

Well, the executable image does not look much like what's on disk,
since it has to be set up by ld.so.  Also, it's highly unlikely that
the disk image is page-aligned in the same way as RAM.  So of course
anything in memory can get swapped (unless it's locked in by a special 
kernel call).

I think you're confusing the swap mechanism (optimizing use of RAM)
with the disk cache mechanism (optimizing use of I/O).
 
    Neil> Then I had a more devious idea. Maybe the old executable is
    Neil> still on the disk, but is just no longer referenced by any
    Neil> directory entries. Its inode's reference count would be
    Neil> still be non-zero, the reference being the currently running
    Neil> instance of the old executable.

    >> This is why you can do something like `prog data; rm data' with
    >> no ill-effects.

    Neil> Sorry, I couldn't glean from your message which method you
    Neil> said it would use with my "wmaker" example. Does it keep the
    Neil> old image on the disk, island-like unreferenced by any
    Neil> directory and marked as free when I exit, or does it load
    Neil> the whole image into memory?

AFAIK the whole file (wmaker or bash) gets loaded into memory (except
for trailing garbage like debug information), the dynamic libraries
get loaded if necessary and linked in, and execution starts.  Whether
it's in RAM or swap, it's somewhere in virtual memory; under normal
circumstances, that process does not need to reference the disk file
again, and in fact doesn't know which parts of the executable are in
RAM or in swap at any given time.  That is decided by the kernel.

-- 
University of Tsukuba                Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Institute of Policy and Planning Sciences        Telfax: +81 (298) 53-5091
__________________________________________________________________________
__________________________________________________________________________
What are those two straight lines for?  "Free software rules."
---------------------------------------------------------------
Next Nomikai: 20 November, 19:30 Tengu TokyoEkiMae 03-3275-3691
Next Technical Meeting: January, 1999 (details TBA)
---------------------------------------------------------------
Sponsor: PHT, makers of TurboLinux http://www.pht.co.jp


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links