Technotes


Virtual Memory Q&As



Technote ME 515October 1990



Revised by: Developer Support Center September 1993
Written by: Developer Support Center October 1990

This Technical Note contains a collection of archived Q&As relating to a specific topic--questions sent the Developer Support Center (DSC) along with answers from the DSC engineers. Current Q&A's can be found on the Macintosh Technical Q&A's web site.


System 7 virtual memory limits with 24- and 32-bit addressing

Date Written: 11/13/92

Last reviewed: 3/1/93

What's the maximum amount of System 7 virtual memory with 24-bit addressing on the following Macintosh models: Classic II, LC II, IIvx, IIvi, Quadras, Performas, and PowerBooks (except 100)? Is built-in video on those models mapped to a NuBus slot space as it is on a Macintosh IIci or IIsi, reducing maximum virtual memory from 14 MB to 13 MB?

___

Below you'll find general formulas that you can use to determine the maximum amount of VM you can have for both 24- and 32-bit addressing, as well as a couple of references that explain VM in further detail. Yes, the built-in video on the Macintosh models you specified are mapped to a NuBus slot space as it is on a Macintosh IIci and IIsi. Think of on-board video as a fake NuBus slot.

The following four factors determine how much VM these Macintosh models can have:

* 24-bit vs. 32-bit addressing

* System management (usually allow it 2 MB)

* Number of occupied NuBus slots (1 MB for each)

* Free disk space.

24-bit addressing

-----------------

The maximum amount of VM that you can have with 24-bit addressing is 16 MB. Note: With 24-bit addressing you're limited to 8 MB physical RAM.

Take the maximum amount of VM that you can have with 24-bit addressing (16 MB) and subtract 2 MB for system management. Then subtract 1 MB for each occupied NuBus slot. To determine how much disk space you must have available, take the maximum amount of VM that you can have and add it to the amount of physical RAM that you have. That's the amount of disk space that you must have free.

Here's an example for a Macintosh II with 8 MB of physical RAM and 2 occupied NuBus slots:

  16 MB  maximum VM with 24-bit addressing
  -2 MB  system management
  -2 MB  for 2 occupied NuBus slots
----
  12 MB  maximum VM for 24-bit Macintosh II with 2 occupied NuBus slots
  +8 MB  physical RAM installed
----
  20 MB  required free disk space

So for a Macintosh II with 8 MB of physical RAM and 2 occupied NuBus slots, you must have 20 MB of free disk space to get 12 MB of VM.

32-bit addressing

-----------------

The maximum amount of VM that you can have with 32-bit addressing is 4 GB. Note: with 32-bit addressing your physical RAM limits are determined by the capabilities of the hardware.

4000 MB  maximum VM with 32-bit addressing
  -2 MB  system management
  -2 MB  for 2 occupied NuBus slots
----
3996 MB    maximum VM for 32-bit Macintosh II with 2 occupied NuBus slots
  +8 MB  physical RAM installed
----
4004 MB  required free disk space

Here's a quick chart of physical RAM and NuBus slots for the CPUs that you inquired.

                                         Expansion slots
CPU                             Physical RAM         NuBus/PDS
---------------------------------------------------------------
Classic II / Performa 200           2-10                 0
LC II / Performa 400                2-10                 1
Macintosh IIvx                      4-20                 4
Macintosh IIvi                      4-20                 4
Macintosh Quadra 700                4-20                 3
Macintosh Quadra 900/950            8-64                 6
Performa 600                        4-20                 4
PowerBook 145                       2-8                  2
PowerBook 160/180                   4-14                 2
Duo 210/230                         4-12                 2

VM XRef:

* Chapter 28 of Inside Macintosh Volume VI, Chapter 28, "Memory Management"

* develop, Issue #6, page 36, "About 32-Bit Addressing" (Developer CD Series disc path: Periodicals: develop: develop Issue 6)

* Macintosh Technical Note "Get Physical" (Developer CD Series disc path: Technical Documentation: Macintosh Technical Notes: Memory: Get Physical)

Macintosh Virtual Memory and protecting large buffers

Date Written: 4/25/91

Last reviewed: 6/14/93

I'm filling a large buffer with one SCSIRead call. What happens if the Macintosh runs under System 7 with virtual memory (VM) and parts of my buffer are swapped out?

___

Parts of your buffer must not be swapped out. Before calling SCSIGet, you must ensure that all code and buffers accessed while the SCSI bus is busy are held in physical memory. If there isn't enough real memory to allocate a full buffer, the application must request smaller blocks (if possible) from the SCSI device, because it's not possible to swap in and out any buffer space during a single I/O operation. Page faults are not serviced while SCSI I/O is in progress. If SCSI I/O is performed at device driver-level Read or Write calls, VM holds your buffer for you. Otherwise, you are responsible for doing this yourself. If there is insufficient physical memory for VM to hold your buffers for you, the Read or Write call fails with an error result.

In general, I/O buffer space used by drivers must be held in real memory for the duration of the I/O operation. This is especially true for SCSI I/O because VM uses SCSI to swap virtual memory in and out, and encountering another page fault would cause a bus error. Device Manager-level I/O handles this automatically, by holding down the appropriate memory when the driver is entered through a Read or Write call. The Device Manager does not take care of this for you when the driver is entered through a Control or Status call, however. If the SCSIRead call is made from within a device driver as a result of a PBRead, no special action is necessary. Any other type of code must be very careful not to cause page faults between SCSIGet and SCSIComplete. This requires holding or placing in the system heap any code or data structures referenced during this time.




Technotes
Previous Technote | Contents