home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / sys / amiga / programm / 15765 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  4.0 KB

  1. Path: sparky!uunet!gossip.pyramid.com!olivea!hal.com!darkstar.UCSC.EDU!cats.ucsc.edu!davids
  2. From: davids@cats.ucsc.edu (Dave Schreiber)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: physical memory protection with MMU
  5. Keywords: mmu, memory, task
  6. Message-ID: <1duvk4INN65q@darkstar.UCSC.EDU>
  7. Date: 13 Nov 92 01:15:48 GMT
  8. References: <1dtp0rINN9jk@uni-paderborn.de> <1du485INNdbn@uni-paderborn.de> <nn.geht.nicht.die-zweite.121192@uni-paderborn.de>
  9. Organization: University of California; Santa Cruz
  10. Lines: 66
  11. NNTP-Posting-Host: si.ucsc.edu
  12.  
  13.  
  14. In article <nn.geht.nicht.die-zweite.121192@uni-paderborn.de> tron@uni-paderborn.de (Matthias Scheler) writes:
  15. >chandler@uni-paderborn.de (Martin Grote) writes:
  16. >
  17. >[stuff deleted]
  18. >
  19. >>However, to focus on my original intention again:
  20. >>- is it impossible / too difficult?
  21. >
  22. >Too difficult, you can't build MMU tables for every 8 bytes of allocated
  23. >memory. If you really would know how a MMU works and how Operating Systems
  24. >with "Memory Protection" work you would know that it is impossible to put
  25. >this in AmigaDOS without loosing 99.9% of the software. It's easy to
  26. >scream for memory protection if you never wrote a program and don't know
  27. >the concept of AmigaOS.
  28.  
  29. Who says you need an eight byte page size, i.e. why does every memory
  30. allocation need to be treated as a separate page?  You could implement
  31. something like this:
  32.  When a task starts, create two lists of memory:  memory allocated by the
  33.   task and memory in the task's address space ("owned" by the task) but not 
  34.   allocated.
  35.  When the task wants to allocate a memory block of size n, do the following:
  36.     1. Search the owned-but-not-allocated memory list for a block of size n.
  37.     2. If no large enough block exists, allocate the necessary memory
  38.        (rounded up to a multiple of the page size, of course) from the
  39.        system heap, change its protection so that it is owned by the task,
  40.        allocate the amount of memory required by the task, and put the 
  41.        remaining memory in the owned-but-not-allocated list.
  42.  When the task frees a block of memory, check to see if this free results
  43.   in an entire page of memory being freed.  If so, remove that page from 
  44.   the owned-but-not-allocated list, change its protections back to "unowned,"
  45.   and return it to the system heap.  Note that this can be done occasionally
  46.   instead of on every FreeMem() if it turns out to be too expensive an 
  47.   operation to run frequently.
  48.  
  49. Using this technique will let you keep the 8-byte minimum allocation size
  50. yet work with large (>=4K on the '040) page sizes.
  51.  
  52. The real problem with memory protection on the Amiga is that it is
  53. possible for one task to share its memory with another without explicitly
  54. telling the OS that the shared memory is in fact shared.  This is a big
  55. nono under a protected OS.  However, it is an exaggeration to say that
  56. 99.9% of Amiga programs do this.  Out of the dozens or so I've written
  57. (some PD, most for my own use), I doubt more than one or two share data
  58. with other tasks (aside from those that have ARexx ports;  I sure hope
  59. MinRexx doesn't break under a protected OS :-)).  Also, I suspect that most
  60. of those programs that do share data with other tasks share data with 
  61. child tasks that are created by the original program using CreateTask(),
  62. CreateNewProc();  I'd bet that if, under a version of AmigaDOS with 
  63. protected memory, CreateTask() etc. created threads (i.e. tasks
  64. that exist in the same address space with their creators, and thus which
  65. can share their creators' data), a lot of compatibility issues could be
  66. minimized.  This would require new system calls that the system program
  67. loader could use to create new address spaces, but that wouldn't affect
  68. user programs.
  69.  
  70. >Matthias Scheler                                         tron@uni-paderborn.de
  71.  
  72. Note: in the above, "task" is being used in the generic form, not in the
  73.       Amiga-specific form.  Also substitute "protected context" for 
  74.       "address space" if it makes you feel better.
  75.  
  76.  
  77. -- 
  78. Dave Schreiber  "Look.  Don't touch."  davids@cats.ucsc.edu (until 6/20/93)
  79.