Newsgroups: comp.os.minix
Subject: Re: virtual memory question
References: <8tqqd0$2keb$1@msunews.cl.msu.edu> <slrn902hnm.h6f.pino+comp_os_minix@mud.stack.nl> <3A019B0D.7719926A@msu.edu>
Organization: Rochester Institute of Technology, Rochester, NY
From: aje9383@osfmail.isc.rit.edu (Andrew Erickson)
NNTP-Posting-Host: grace.isc.rit.edu
X-Original-NNTP-Posting-Host: grace.isc.rit.edu
Message-ID: <3a01f149@news.isc.rit.edu>
Date: 2 Nov 2000 17:57:13 -0500
X-Trace: 2 Nov 2000 17:57:13 -0500, grace.isc.rit.edu
Lines: 69
XPident: aje9383
X-Original-NNTP-Posting-Host: 129.21.4.100
XPident: Unknown
Path: news.adfa.edu.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!intgwpad.nntp.telstra.net!newspump.monmouth.com!newspeer.monmouth.com!howland.erols.net!bloom-beacon.mit.edu!news.kodak.com!news-nysernet-16.sprintlink.net!news.sprintlink.net!news.isc.rit.edu!aje9383
Xref: news.adfa.edu.au comp.os.minix:36051

In article <3A019B0D.7719926A@msu.edu>, Davis Ford  <forddavi@msu.edu> wrote:
>Martijn van Buul wrote:
>> 
>> It occurred to me that Davis Ford wrote in comp.os.minix:
>> > What is the purpose of having virtual addresses in minix, then if they are
>> > not used in a paging system?  Is it for protection, perhaps?
>> 
>> Virtual memory isn't the same as paging. You could have two programs share
>> the same code segment (or a piece of the datasegment on a copy-on-modify
>> basis). Especially the latter one requires a virtual memory system,
>> but is not related to paging at all.
>
>I wasn't necessarily thinking that virtual memory and paging were the
>same thing, the
>way I understand it, virtual memory addresses are a way of implementing
>a paging system, but the two can
>be mutually exclusive.  Anyway, so if two programs share the same code
>segment, why not just share the same
>physical address - again, is this for protection, because of lack of
>hardware support, for instance.  

Virtual memory simply means somehow translating logical addresses, as seen
by the process, into physical addresses in RAM using something other than
the identity function.  That is, the address a program sees is not the
physical address in RAM.  (I think you already knew this, but I wanted to
be sure we were all agreeing on what we were talking about. :) )

That said, there are many reasons to use virutal memory:  to prevent having
to relocate programs when they are loaded (or, equivalently, having to use
only position independent assembly code); to allow sharing of text after
a fork(); to permit dynamic resizing of process spaces; to allow paging or
swapping to disk; to ensure protection between processes; and probably a
bunch of others.

Probably the biggest driving force behind Minix's use of virtual memory is
the fork() call; with only a fixed, flat address space, there is no
efficient way to have two identical process images which run separately.
(Minix versions for 68K systems have this problem; they constantly swap
process images around in memory after a fork() until a wait() or an exec();
this does cause big performance problems in some circumstances, and less
big ones in many others.)  Protection and shared text are nice side effects,
too.  Minix does not allow processes to grow, but that wouldn't be too
difficult to graft in (albeit rather inefficiently) by rearranging the
segments in the memory map when resizing a data or stack segment.

>Let me state it more clearly this way: the reason minix uses virtual
>memory then, is for the purpose that two processes might want to share
>the same segment (as in text, data, stack).  However, the memory
>hardware may not provide bits that indicate both referenced and modified
>status of memory, so this sharing becomes problematic.  This is the
>reason virtual memory is needed, in order to share these segments
>between processes, and to provide the extra information that the
>hardware might not support (referenced and memory bits).   Am I correct
>in these assumptions?  Please straighten me out, if not.  Thanks in
>advance!

Sharing segments is sometimes useful, but not as much a driving force as
the fork() issue above.  Text segments are shared among processes in Minix,
at least under some circumstances (fork()ed processes, at least), but there
is no way to share data or stack segments; and, without special application
programming, the results would often be disasterous.  Minix treats segments
as units, so using shared memory to commuincate between two processes, which
are otherwise independant, would be impossible (without massive changes to
the memory management theory, at least).

>Davis

-- 
Andrew Erickson
