ADC Home > Reference Library > Technical Notes > Legacy Documents > Hardware & Drivers >
Important: This document is part of the Legacy section of the ADC Reference Library. This information should not be used for new development.
Current information on this Reference Library topic can be found here:
|
Setting the Current Zone for Macintosh System ExtensionsDate written: 1/15/92 Last reviewed: 6/14/93 Sometimes when my system extension (INIT) starts executing, the current zone is the system zone rather than the application zone. Should I call SetZone(ApplicZone) before allocating memory in the system extension? ___ The system does not set the zone to the application zone before loading each system extension, so if a previous extension left the zone set to the system zone, it's possible that an extension could unintentionally be loaded into the system heap and have the current zone be the system zone. To ensure that nonpermanent memory requested by a system extension is allocated
in the application heap, do a Any permanent memory allocation by a system extension should be made in the
system heap with Macintosh disk drivers and memory allocationDate written: 9/11/92 Last reviewed: 6/14/93 Our disk driver needs to allocate a large amount of space, and on some machines the amount of system heap space at boot is limited. What can we do to ensure enough system memory for our driver? ___ Drivers that require more than the default amount of heap space need to adjust the size of the system heap directly. The following code is used by Apple's current SCSI disk driver to increase the system heap at boot time. This adjustment should be as minimal in size as necessary. It works with 8K, but there are upper limits. This code should be used in the driver's install routine. It's important that the driver does this as the very first step, after performing the checksum on the driver code if you use one. This code will fail after boot time.
A SCSI driver being loaded will be passed D5 with the high byte clear, and the low byte containing the SCSI ID. If the high byte is clear, it's a good bet that it's boot time. If your application is installing the driver, such as the formatter/installer utility, it should set the high bit of D5. When the driver's loader code gets called, it will test D5 for this bit being set. When this bit is set, you'll know not to perform the adjustment to the system heap. Or you can use the following method from the original sample SCSI driver:
Additionally, if more memory is necessary the driver can set the If an INIT is to install the driver, use the When to use SetCurrentA5Date written: 11/11/90 Last reviewed: 5/21/91 During a Macintosh application's life, does the value of A5 change? Why does
___ A5 is not necessarily always equal to Because the operating system or Toolbox can change A5, you must make sure it's
set correctly if the operating system or Toolbox ever calls your code in the
form of a callback. For example, if you make an asynchronous File Manager call,
your I/O completion routine must call Please note that even Macintosh GrowZone routine is not reentrantDate written: 12/10/90 Last reviewed: 6/14/93 My Macintosh application receives information from the serial port, keeping as
much information in memory as possible. However, if I do run out of memory, my
___ Neither the Keep a list of handles to blocks of text that you're willing to purge, so that
your By the way, Increasing heap space for Macintosh DAsDate Written: 3/12/91 Last reviewed: 6/14/93 I am writing a Macintosh desk accessory (DA) that opens large PICT files and makes off-screen pixel maps for them. Is there a way for a DA to ask for more space when it opens up, or should we be modern about this and make it an application instead of a DA? ___ A DA, like any application, can ask for available MultiFinder temporary memory, as documented in Programmer's Guide to MultiFinder for running under System 6.0.x and in Inside Macintosh Volume VI for running under 7.0. You can also set the current heap to the system heap so that memory allocation will take place there until you set it back to the current heap. If you do this, you open up the can of worms of "how much space is left in the system heap?" Under Finder there's a fixed amount of space, set by the boot blocks. Under MultiFinder (and System 7.0) the system heap adjusts itself to keep about 16K free, but if you allocate all 16K you will not know when it will resize larger or when the system might crash because all of its heap space has been used up. DAs, however, were never intended to use large amounts of memory. For all but the most trivial (and small) functionality, it is better to implement as an application than as a DA, especially under System 7.0 where an application has all the advantages of a DA with none of the restrictions. Sharing data between Macintosh applicationsDate Written: 8/23/91 Last reviewed: 6/14/93 What are the preferred methods for sharing data between applications? I want to use the Program-to-Program Communications (PPC) stuff or Apple events to dynamically link libraries, but the size of the data blocks to be passed between the applications makes copying them around unacceptable. The best method would be to somehow share the data and remain compatible with future systems (presumably with memory protection). How is the system heap on handling large chunks of memory? ___ As you point out, there could be some memory protection someday, but at this time there's no indication of how shared memory will be allowed under these tighter rules.For the time being, if you are willing to pay the consequences later, then the following might help: The 4 bytes of an address for a location in memory could be passed as data in a PPC data transfer, or Apple events could carry the information. Secondly, the Gestalt mechanism could be used to pass an address between processes or tasks. For your problem this probably is better then the other forms of IPC. The best thing to do is allocate a shared handle in the system heap. HLock the block only when necessary. Remember, the system heap grows dynamically under System 7.0. Preloading and locking Macintosh code segmentsDate Written: 6/8/92 Last reviewed: 9/15/92 What is the correct way to preload and lock all of a Macintosh program's segments? ___ The best way to preload and lock segments is to use the Resource Manager. Just
set the Preload and Locked bits on the segment resources. This will cause all
these segments to be loaded contiguously, low in the heap. To avoid
fragmentation, you should leave these segments loaded all the time; never call
An alternative is to put everything into one big segment using Macintosh system heap limitationsDate Written: 7/13/92 Last reviewed: 6/14/93 In System 7, the memory allocated for INITs by the ___ The system heap size at startup is limited to approximately half the size of
total RAM. This is because the early startup code places the stack and some
globals in the middle of RAM so that the system heap can grow up from below
while Downloadables
|
|