From mint-bounce@lists.fishpool.fi Tue Dec 9 18:14:52 2008 X-SourceIP: 77.249.75.167 Message-ID: <493EFB19.8050907@chello.nl> Date: Wed, 10 Dec 2008 00:11:21 +0100 From: Henk Robbers User-Agent: Mozilla Thunderbird 1.0.2 (Macintosh/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: MiNT Mailing List Subject: [MiNT] Virtual memory design References: <1175807537.739034.175070@o5g2000hsb.googlegroups.com> In-Reply-To: <1175807537.739034.175070@o5g2000hsb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: h.robbers@chello.nl Precedence: bulk List-help: List-unsubscribe: List-Id: X-List-ID: List-subscribe: List-owner: List-post: LS Based on very unspecific general knowledge of virtual memory. I have no idee whether these thoughts have any practical value. The 3 idees are independant of each other. They heve nothing to do with today implementations. -------------------------- 1 ---------------------------- It should be possible to completely disentangle a virtual store manager (VSM) from the actual operating system. Implement a VSM as a bottom layer underneath anything else. A VSM is the only part of the software that runs in physical address space. It is booted first. When booted it prepares a swap file and sets up a page tree describing all left over memory in which to load the first program. This program could be anything, so why not a operating system. The OS runs in virtual memory all the time. The VSM only needs a few functions: 1 Create a virtual addres space of a given size. 2 Extend a given virtual address space by a given amount. 3 Contract a given virtual address space by a given amount. 4 Destroy a given virtual address space. These function are made available via software interrupts (classic system calls). The VSM only needs to know about address spaces. Processes are OS concepts. The functions of a VSM are only available in kernel mode. The VSM functions are used by the kernel for its own requests and to accomodate memory requests from user code. A certain amount of the OS virtual address space can be mapped to physical address space to accomodate refering to page trees, interrupt vectors and other things depending on architecture. It is easy to make a version of a OS for use without such a VSM. Just implement simple versions of the VSM calls in the OS itself. ---------------------- 2 -------------------------- A nice idee would be for a OS to be able to keep its memory model flat, including all user code. This can be achieved by doubly mapping user memory. Once normally and once in the address space of the OS, such that the virtual address space of a user process is part of the OS address space as continuous adjacent virtual memory regions. The only thing the OS need to know is the start address and size. (Datum & limit in certain old mainframes). Locations within those address spaces can be refered to by the OS through simple indirection. Extending address space only needs updating page trees. It makes sparse memory look dense. In this case the VSM needs appropriate paramaters to its functions. The model is not suited for clumsy implementations of shared or public code. Especially not when fixed virtual addresses are used. It is not suited for 'top of address space' stacks as well. ------------------------- 3 -------------------------------- Another nice idee would be to implement segmentation. The first level page table is the segment table. The first 10 bits of the address is the segment number. Segment displacements start at 0 and are maximuum 4Mb. Due to lack of a segment linit field, the segment size is determined by the number of valid 2nd pagetable entries. Segments can be shared by address spaces. The 2nd level page table describes the same pages, but the segment number can be different. All segments start at 0 :-) Malloc OS chunks are a new segment each. As is the stack. The stack must grow upwards so it actually *can* grow. Henk Robbers