Article View: comp.sys.powerpc
Article #2397Re: Ask yourself these before you choosing a 32bit OS...
From: Kazimir Kylheku
Date: Mon, 02 Oct 1995 16:30
Date: Mon, 02 Oct 1995 16:30
48 lines
3476 bytes
3476 bytes
In article <44krqn$9qq@vixen.cso.uiuc.edu>, Steve Peltz <peltz@cerl.uiuc.edu> wrote: >In article <446ofvINN97n@keats.ugrad.cs.ubc.ca>, > >If you, as an application programmer, want to do your own memory management, >just allocate pointers rather than handles. The only time you have to use >handles is when dealing with those parts of the OS that need them (and >typically, those are parts where handles make sense - the object may change >size, e.g. a region). Right, we already settled this when Nevin Liber kindly pointed out that the Mac never uses handles for memory _management_, only for dynamic allocation that is done on a per process basis independently of other processes. The MacOS memory management consists of chopping up the physical address space into partitions whose size is determined before the program is loaded. It's not a completely unreasonable strategy if you don't have a MMU, though it fails for any applications whose memory usage is unpredictable, or very variable (e.g. a multi-threaded server whose load drastically varies with time). Handle-based allocation is flexible: if you don't want the compaction, you can just put a malloc() wrapper around the allocator routine that locks everything. Unfortunatley, if you want pre-emptive threading within one process, and have your threads allocate handles from the same heap, it's not practical to allow the compaction. If you do, you have to make sure that each access to a handle is atomic. In other words, as long as you are using a temporary pointer that was derived from a handle, that handle either has to be locked, or you have to prevent pre-emption or the execution of any routine that may bring about compaction. For instance, if you are chasing a linked list, you have to lock and unlock each node in turn. I have thought of an implementation which would store along with each allocated node the ID of the thread that allocated it, so that whenever it is convenient, all of the blocks belonging to a particular thread (or several threads) can be treated as locked items. It's a lot of trouble to go through to eliminate a worst-case allocation scenario, in which N allocated cells can occupy a (1 + r)N footprint (where the maximum size of an allocated block is 2^r) [For proofs, see the paper by J. M. Roberts, JACM Vol. 18, 1971]. In practice, this won't happen, for it requires a purposeful allocation strategy carefully designed to foil any coalescing scheme. Threading throws in a randomizing element that makes the worst case even more unlikely than in a single-threaded process. It might be worth it to have a thread-safe allocation library that supports compaction. -- PGP key id is 0xD3C7995D. Molybdenum 95! Got your ounce of fission byproduct yet?
Technical Details
Message-ID:
<44p42eINNe09@anvil.ugrad.cs.ubc.ca>Path:
arc1-ca.pugleaf.net!anvil.ugrad.cs.ubc.ca!not-for-mailReferences:
<3vh2hc$9dd@falcon.ccs.uwo.ca> <445369$o2n@orion.cybercom.net> <446ofvINN97n@keats.ugrad.cs.ubc.ca> <44krqn$9qq@vixen.cso.uiuc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!anvil.ugrad.cs.ubc.ca!not-for-mail From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) Newsgroups: comp.sys.powerpc,comp.os.linux.advocacy,comp.sys.mac.advocacy,comp.os.os2.advocacy,comp.sys.amiga.advocacy,comp.sys.intel,comp.os.ms-windows.advocacy Subject: Re: Ask yourself these before you choosing a 32bit OS... Date: 2 Oct 1995 09:30:06 -0700 Organization: Computer Science, University of B.C., Vancouver, B.C., Canada Message-ID: <44p42eINNe09@anvil.ugrad.cs.ubc.ca> References: <3vh2hc$9dd@falcon.ccs.uwo.ca> <445369$o2n@orion.cybercom.net> <446ofvINN97n@keats.ugrad.cs.ubc.ca> <44krqn$9qq@vixen.cso.uiuc.edu> NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca