Inside
the System File
The System file contains routines and
resources responsible for running the computer. This section
describes system features and corrections built into the
System file. These items are always present under System
7.6, even when the shift key is held down at system startup.
General Features
Some of the system's more frequently used
shared libraries have been moved from resources in the
System file into the System file's data fork. This change
allows the system to use file mapping on these libraries
when virtual memory is turned on, thus allowing the space
they occupy in memory to be used for other purposes when
necessary. The benefits from this change are twofold:
- There is more memory available for applications and
other services.
- For debugging purposes, when virtual memory is
enabled, applications making calls that are illegal at
interrupt time are more likely to cause bus errors,
making it easier for developers to find problems in their
software.
A problem in the interrupt dispatching code on PCI-based
systems where it was possible for a level 4 interrupt
handler to be called with interrupts masked only to level 3
has been corrected. This correction was previously provided
by the PowerPC Interrupt Extension.
Assistant Toolbox 1.3
The Assistant Toolbox provides the user with
assistance or warnings when the user attempts to do
something that may cause internal system configuration
conflicts. In some cases, the Assistant Toolbox performs
actions automatically if no user intervention is required.
The Assistant Toolbox has been moved to the System file,
so it cannot be disabled when the system starts up. If the
Assistant Toolbox extension is present while Mac OS 7.6 is
being installed, it will be removed.
In some cases, when returning from Sleep, the volume
remounting code was attempting to remount volumes that had
already been mounted. The Sleep mounting code now
appropriately checks to see if a volume has already been
mounted when returning from Sleep before attempting to
remount it.
Code Fragment
Manager
The Code Fragment Manager (CFM) is
responsible for the retrieval of executable PowerPC
instruction sequences on PowerPC computers. Almost all of
the PowerPC Mac OS and all PowerPC applications depend on or
utilize the services of the CFM in some way.
CFM's algorithm for finding shared libraries has been
simplified. The last three stages of the searching strategy
used by CFM, as described in Inside Macintosh: PowerPC
System Software 3-7 (the Extensions folder in the System
Folder, the ROM registry, and then CFM's internal file and
directory registry), have been combined into a single step.
This change in search strategy ensures that the most recent
version of an import library will be loaded by CFM when
there are multiple versions of the same library present in
the System file, the Extensions folder, the ROM, or all of
the aforementioned.
See also Inside Macintosh: PowerPC System
Software 3-7 at
<http://developer.apple.com/techpubs/mac/PPCSoftware/PPCSoftware-41.html>
Disk
Initialization Package
The Disk Initialization Package provides
formatting services for disk drives.
HFS does not support 720K diskettes. The dialog box
informing the user that he or she cannot reformat a 720K DOS
disk as a 720 HFS disk now draws correctly.
Display Manager
The Display Manager provides software
services for managing changes in both the display settings
and the arrangement of monitors attached to Mac
OS-compatible computers.
DisplayLib has been moved to the data fork of the System
file.
Drag
Manager
Macintosh Drag and Drop provides standard
communications and user interface services for applications
and other parts of the system that are used when users "drag
and drop" objects between locations.
DragLib has been moved to the System file's data fork.
File
Manager
The File Manager provides services for
storage and retrieval of disk-based information on Mac
OS-compatible computers. Mac OS 7.6 includes several changes
in the File Manager's implementation, providing improved
performance and reliability. The following describes new
features and facilities provided in the Mac OS 7.6 File
Manager implementation:
Cache-Related:
- A task has been added to the File Manager's disk
cache that periodically flushes dirty cache blocks to
disk. With this change, data that should be written to
disk will never be left in the cache for an extended
period of time. The task runs once a second when there is
no other disk activity. One file's dirty cached blocks
are flushed each time the task runs. Cached volume blocks
- files with file numbers less than 16 and cached blocks
not associated with any files (such as the master
directory block and the volume bitmap blocks on HFS
volumes) - are flushed as a set.
- If extensions are disabled (i.e., the shift key is
held down at startup), the new file system cache will be
loaded, replacing the ROM cache, and its size will be
temporarily set to 96K. Previously, when extensions were
disabled, the ROM version of the disk cache would be
used.
- Many high-performance disk drives and some disk
drivers utilize a private write cache mechanism
independent of the File Manager's cache to enhance
performance. Because of this, it is possible that even
though the file system has carried out appropriate writes
to a disk driver when flushing a volume, some of the
information may still reside in the disk drive's or disk
driver's cache and can be lost in the event of a power
failure. In response to this possibility, a disk driver
that supports the DriverGestalt
'flus'
selector is called with the DriverConfig
'flus' selector whenever that disk volume's
cache is flushed in response to a File Manager FlushVol
or UnmountVol request.
Other File Manager Changes:
- FlushFile was updating the reserved system area in
the first block of resource forks on HFS volumes, which
caused problems for certain third-party caching software
and WORM disk drivers. That behavior has been removed for
both compatibility with those software packages, and to
improve HFS file system performance. The reserved system
area in the first block of a resource fork is still
updated when a resource fork is closed on an HFS volume.
- The File Manager supports volume sizes up to 2
terabytes on all Macintosh systems with an 68040 or
PowerPC processor. Macintoshes with 68030 processors are
still limited to 4 gigabyte volumes.
- To reduce the long boot times after an improper
system shutdown, the mount-checking code for HFS volumes
was rewritten. In some cases, it was taking up to 5
minutes to mount a drive. With the new mount check, the
worse case time is on the order of seconds. However, a
change was needed in the method used to detect volumes
which must be checked.
The original mount check code (in ROM) uses the
vcbAtVOK bit (bit 8) in the drAtrb field of an HFS
volume's master directory block (MDB) to determine if a
volume was unmounted correctly. The vcbAtVOK bit was
cleared on disk when the volume was mounted and set on
disk when the volume was unmounted correctly. If vcbAtVOK
was clear when a volume was mounted (meaning the volume
was not unmounted correctly), then the mount check code
quickly checks for, and corrects if necessary,
inconsistencies between the volume bitmap, the master
directory block, and the catalog files.
The new mount check code uses the same mechanism to
detect when a volume was not unmounted correctly.
However, because the boot volume is mounted and would be
checked by the original mount check code before the new
mount check code can be loaded from the System file, a
new volume attribute kBootVolumeInconsistent (bit 11) has
been introduced. When the boot volume is mounted, the
kBootVolumeInconsistent bit is set and the vcbAtVOK bit
is set in the MDB. When the boot volume is unmounted,
kBootVolumeInconsistent bit is cleared. After the new
mount check routine is loaded, the first thing it does is
check the boot disk to see if the kBootVolumeInconsistent
bit is set and if so, it checks for, and corrects if
necessary, any inconsistencies found.
Table 1 illustrates how the new mount check code uses
the vcbAtVOK and kBootVolumeInconsistent bits on both
boot and non-boot volumes.
Table 1. Mount check codes for boot and
non-boot volumes
Boot Volumes
|
Interpretation:
|
unmounted OK
|
unmounted bad
|
mounted
|
vcbAtVOK
|
1
|
0
|
0
|
kBootVolumeInconsistent
|
0
|
1
|
1
|
Non-boot Volumes
|
vcbAtVOK
|
1
|
0
|
0
|
kBootVolumeInconsistent
|
n/a
|
n/a
|
n/a
|
Note:
Copies of Disk First Aid earlier than version
7.2.3 assume that kBootVolumeInconsistent is
reserved and should be zero and incorrectly
report the volume as damaged when it is probably
not damaged and instead was only unmounted
incorrectly.
|
- PBCatSearch usage of the File Manager cache has been
changed, so that it can now search a volume's catalog up
to four times faster (when compared to System 7.5.3).
- The Mac OS file system uses the
EqualString (now CmpString ),
RelString , and UprString
routines for file name searching and comparison. In every
call to these routines, the File Manager sets the
diacSens parameter to TRUE, so that diacritical marks are
significant in comparisons. However, PBCatSearch was
setting the diacSens parameter to FALSE, in some cases
leading to inconsistent behavior relative to the rest of
the File Manager's routines. PBCatSearch now always sets
the diacSens parameter to TRUE for all comparisons.
Font
Manager
The Font Manager provides services for
retrieval of glyphs used in the display of textual
information on Mac OS-compatible computers. There is one
correction in the Font Manager:
Previously, calls to RealFont would release
and reload the current 'sfnt' resource,
possibly invalidating the Font Manager's cache, since parts
of the cache depend on the handle not changing. This problem
was only apparent in multi-byte character systems.
Memory
Management
Memory management includes the Memory
Manager, virtual memory and other operating system services.
The following changes to memory management have been
implemented:
- On PowerPC computers, the Modern Memory Manager is
always active and the classic 68K Memory Manager is not
available.
- System 7.6 only supports 32-bit addressing. 24-bit
addressing is no longer supported. If the computer's
Parameter RAM (PRAM) settings indicate that the machine
is in 24-bit mode at system startup, the PRAM is set to
32-bit addressing and the computer is restarted.
- Since 24-bit mode is no longer supported, most checks
for 24-bit mode and calls to
SwapMMU have
been removed from the virtual memory routines, thus
reducing the calling overhead.
- Virtual memory page fault execution times have been
shortened by removing 24-bit runtime code.
- The Modern Memory Manager on PowerPC computers now
communicates directly with the Virtual Memory Manager to
greatly reduce page fault disk accesses to the VM backing
store file.
- Allocating and deallocating temporary memory is much
faster.
Menu
Manager
The Menu Manager is responsible for drawing
the menu bar and drawing menus and pop-up menus on the
screen while the mouse is being held down. The following
changes have been implemented:
- The system MDEF=0 was calling
GetMaxDevice specifying a boundary in local
coordinates of the current GrafPort rather than in global
screen coordinates. Normally, on multiple monitor
systems, this means menus would be drawn according to the
features of the main screen, rather than the screen
containing the menu. However, by specifying the boundary
passed to GetMaxDevice in local coordinates
of the current GrafPort, it was possible for
GetMaxDevice to return NULL, the one case
the MDEF=0 did not handle correctly. The new MDEF=0
passes the global coordinates to
GetMaxDevice and handles the NULL result
correctly.
- It was possible for calls to
CalcMenuSize to call through to an MDEF with
ResLoad set to FALSE. In the event that the
MDEF attempted to access resources that were not already
in memory by calling GetResource , empty
handles would be returned to the MDEF, which may not have
been what the MDEF expected. CalcMenuSize
has been corrected, so ResLoad is set to
TRUE before the MDEF is called.
- A problem in the Standard MDEF where color icons
drawn in popup menus were not appearing on some monitors
has been corrected.
- The Menu Manager normally saves the image under a
menu in an off-screen buffer before drawing the menu, so
it can be restored immediately after the menu is removed
from the screen. For menus drawn outside of the screen's
visible area, there is no image under the menu to save
and the off-screen buffer is not created. But, in such
cases, the routine's epilogue mistakenly assumed that the
off-screen buffer was created and attempted to reclaim
the memory it would have occupied. This would cause a
system crash when the mouse was released after tracking a
pop-up menu that was drawn completely outside of the
screen's boundary. This possibility has been removed and
the routine's epilogue no longer attempts to dispose of
the nonexistent buffer in such cases.
- A problem where the MDEF was calculating the size of
icons appearing in the Apple Menu incorrectly has been
corrected.
PictWhap
FKEY
FKEYs are code resources in the System file
which are invoked by command-shift-number key sequences,
where the number is the ID of the resource. For example,
FKEY=3 is invoked by typing the number 3 while the command
and shift keys are held down. It captures the contents of
all screens into a PICT file in the root directory of the
startup disk.
- PictWhap is a new FKEY=4 for capturing screen shots
as PICT files. When invoked via command-shift-4, PictWhap
presents the user with a small crosshair cursor to allow
the user to select a rectangular area of the screen to
capture as a PICT file.When invoked via command-shift-4
while the caps lock key is down, it presents the user
with a bullseye cursor. When the user clicks on a window,
its contents are saved as a PICT file. If the control key
is held down, the image is captured to the Clipboard
instead of a PICT file.
- The Screenshot FKEY=3, command-shift-3, has been
revised so that when the control key is held down, it
will capture contents of all screens to the Clipboard
instead of a PICT file.
Process Manager
The Process Manager shares the processor
among multiple applications. Some corrections to problems
found in the Process Manager have been provided in Mac OS
7.6 as follows:
Resource
Manager
The Resource Manager is used for storage and
retrieval of information stored in the resource fork of many
Mac OS files. Almost all programs make use of the Resource
Manager.
The PowerPC Resource Manager has been improved in the
following ways:
- The Resource Manager has been moved into the data
fork of the System file to allow for file mapping when
virtual memory is turned on.
- Routines have been simplified to reduce execution
time. This does not mean there will be a drastic
improvement in Resource Manager execution speed; however,
since many parts of the operating system utilize the
Resource Manager services, there is an overall
improvement in system performance.
- A resource size cache has been added to retain
information about frequently accessed resources in
memory. This does not mean a major performance gain for
all application resources in general; however,
performance improvements are noticeable for some system
resources (such as color tables), which are accessed
repeatedly by the system and applications.
- The Resource Manager "knows" to flush the Font
Manager's cache when sfnt's are released by calling
ReleaseResource . Parts of the Font Manager's
cache depend on the font handle for the active sfnt not
changing when it could be changed by a call to
RealFont .
- Calls to
HOpenResFile failing with some
result other than opWrErr (-49, File already open with
write permission) would leave 40 bytes of handle data
floating on the heap. Note: Some developers may not have
noticed this problem when running with debuggers that
patch low-level Resource Manager vectors and later fall
through to the 68K Resource Manager (which does not
contain this bug).
The 68K Resource Manager has been improved in the
following ways:
- A
GetResource patch was calling
FlushCodeCacheRange on every call. This has
been corrected, so FlushCodeCacheRange is
called only when necessary.
Script
Manager 7.5
The Script Manager provides facilities for
display and retrieval of number, date, time, and other
information in a language-independent way.
- The routine
StringToExtended has been
updated to provide better error checking for strings that
do not match the format string.
- The routines
StringToFormatRec and
StringToExtended are now installed in a way
that avoids unnecessary mixed mode switches when they are
called.
- An error in
StringToFormatRec where a
unpredictable memory location was being modified by the
routine has been corrected.
SCSI Manager
(PowerPC)
The PowerPC SCSI Manager is responsible for
communicating with connected SCSI devices on PowerPC
computers.
On some systems with the Power Macintosh Card 1.0
installed, a SCSI Manager hang could occur during periods of
high network activity. This problem occurred because the
SCSI Manager was only polling for interrupts when the
interrupt level was 2 or higher, leaving a SCSI Manager
deferred task pending. Now, to correct this problem, the
SCSI Manager polls for interrupts when the interrupt level
is set to 1 or higher on those machines.
Sound
Manager 3.2.1
The Sound Manager provides services for
playing and recording sounds on Mac OS computers. The new
Sound Manager is built into the System file. If there is a
Sound Manager extension in the Extensions folder when Mac OS
7.6 is being installed, it will be removed.
SPBSetDeviceInfo , when passed the
siVoxRecordInfo selector, now starts
recording even if the trigger value is 255. (See also
Inside Macintosh: Sound at
<http://developer.apple.com/techpubs/mac/Sound/Sound-149.html>,
p. 3-25.)
- On some models, code maintaining the volume control
buttons on the front of the machine was calling
SetSoundVol at interrupt time, which could
lead to a system crash. Previously, installing the Video
Startup system extension would correct this problem, and
it has been corrected in Mac OS 7.6.
SPBGetDeviceInfo , when passed the
siStereoInputGain selector, now correctly
returns two 16-bit (8.8) fixed point numbers on PCI-based
machines. Previously, this call would attempt to return
two 32-bit (16.16) fixed point numbers, trashing the
stack.
- The
siVoxStopInfo selector used with
SPBGetDeviceInfo was returning incorrect
values on some PCI-based machines (e.g., Power Macintosh
7500, 8100, and 8500 computers) running system 7.5.2 or
7.5.3. This problem has been corrected and
siVoxStopInfo now returns the correct values
on those machines.
Standard File
Standard File provides a consistent user
interface for accessing files by way of the Open and Save As
dialog boxes.
A problem where CustomPutFile would crash
when an additional editText item was added to
the dialog has been corrected.
StdCLib
3.4.3
StdCLib is a shared library located in the
ROM on all PowerPC-based Macintosh computers that provides
functionality for programs compiled using the C language.
Mac OS 7.6 includes a new version of this library that
replaces the ROM library, providing many corrections and
improvements. Previous updated versions of the StdCLib
shared library were available in the StdCLibInit extension,
which is no longer needed and will not install itself during
the Mac OS 7.6 startup sequence. The new StdCLib shared
library now resides in the data fork of the System file.
Most of the features and corrections provided by the
StdCLib 3.4.3 have to do with the handling of invalid
parameters, so applications calling the routines with
correct parameters may not have noticed any problems.
The following changes have been implemented:
- macros LDBL_EPSILON, LDBL_MAX, and LDBL_MIN defined
in <float.h> (corresponding to entry points
"_LDBL_EPSILON", "_LDBL_MAX", and "_LDBL_MIN") are now
correct for the PowerPC. The versions contained in the
ROM-based StdCLib were not valid.
- The number of files that can be simultaneously open
using the StdIO routines
fopen() ,
fdopen() , and freopen() has
been increased from 20 to 40 files (the value of _NFILE
in <stdio.h>).
strftime() now conforms to the ANSI
standard recognizing an uppercase %P rather than a
lowercase %p for the AM/PM format character.
setvbuf() now returns USHRT_MAX if too
large a buffer is requested. The setbuf() function never
allocates a buffer larger than 65535 bytes.
fread() performance has been improved on
unbuffered streams.
- The
sscanf() function's %n option was
corrected to return the correct number of characters when
the matching item goes to the end of the string (with no
spaces following the item).
- The
PLstrpbrk() function was updated to
handle empty strings correctly.
- The
bsearch(key, base, nmemb, size,
compar) function was corrected so it no longer
hangs when the value of nmemb is zero.
- The
strncpy() function no longer copies
65K characters when called with n = 0.
- The creator and type for files of type TEXT is set to
SimpleText. And, in particular, the creator and type for
the output files "stdout" and "stderr" are now 'ttxt' and
'TEXT', respectively.
- fopen now sets errno EACCESS when an attempt to open
a locked file with write permission ("w") is made when
file sharing is turned on. This problem only occurred
when file sharing was turned on--the afpAccessDenied
(-5000) result code was being ignored.
strlen() now returns zero when the NULL
pointer is passed as a parameter. Previous versions read
data from location zero.
strtol(const char *nptr, char **endptr, int
base) was corrected to comply with the ANSI
standard in cases where no conversion is performed. The
ANSI standard says: "If the subject sequence is empty,
does not have the expected form, no conversion is
performed; the value of nptr is stored in the object
pointed to by endptr, provided that endptr is not a null
pointer." (page 153) nptr is now correctly copied to the
object pointed to by endptr when no conversion occurs.
- The
strcmp() and strncmp()
functions have been updated to use unsigned comparisons.
PLpos() has been corrected to return
zero instead of one when passed two empty strings as
arguments.
PLstrcat() now handles the case where
the destination string already contains the maximum
number of characters correctly.
PLstrchr() has been corrected to handle
the case where the target string is empty.
fclose() now sets errno to ENOENT when
passed a closed file descriptor.
fcntl(F_DUPFD) calls now set errno to
EBADF rather than EINVAL when bad file descriptors are
passed in.
- A problem related to parsing long path names
containing embedded folder aliases has been corrected.
strncat() will now copy no characters
from the source string if the n parameter is zero.
Previously, it would copy up to LONG_MAX characters from
the source to the destination if the n parameter was
zero.
- The routine
mbtowc () now returns -1
when the number of characters to examine is zero.
Known problems and limitations:
- The character inquiry routines
isalpha(),isupper(),islower(),isdigit(),isalnum(),isspace() ,
and isprint() will only function correctly
for 7-bit characters and the value EOF. They do not
support the Macintosh extended character set.
- If
abort() is called, routines
registered with atexit() and C++ destructors
are still called even though they shouldn't be.
malloc() is limited to about 8 megabytes
per call. If more than 8 megabytes are requested, NULL
will be returned.
- Reading past the end of a file using
fread() does not cause an appropriate error
to be reported in the global variable errno or by the
function ferror() , although
fread() does correctly return the number of
bytes actually read.
- An attempt to
raise() an invalid signal
does not report an error.
- An attempt to install a signal handler for an invalid
signal does not cause
signal() to report an
error.
System Error
Alert
The System Error Alert box is displayed as a
last ditch attempt to inform the user that a serious, often
unrecoverable, system error has occurred. In some cases,
because of how certain low-memory structures were arranged
when the alert was invoked, the alert was not being
displayed correctly.
The System Error Alert was causing a system error and
calling itself repeatedly when certain low-memory font
structures were not yet initialized. The net effect was the
appearance of a continually flashing error alert box on the
screen. The system now makes greater effort to ensure these
structures are set up correctly at all times, especially
during the system startup sequence and during the launching
of applications.
QuickDraw
QuickDraw is used for drawing and displaying
information on the screen. MacOS 7.6 provides the following
corrections in QuickDraw:
OSErr SetPixMapRowBytes
(PixMapHandle pixmap, unsigned short newRowBytes) {
// rowbytes must be even and less than 0x4000.
// for best performance, it should be a multiple of 4.
if (newRowBytes >= 0x4000 || (newRowBytes % 2) != 0) {
return paramErr;
} else {
(**pixmap).rowBytes = (newRowBytes | 0x8000);
return noErr;
}
}
|
- A problem in the Palette Manager where a division by
zero error occurred when calculating the best matching
color on a direct device has been corrected.This would
only happen in calls to
SetDragImage() when
at least two monitors were attached to the system with
one monitor in direct mode and another in indexed mode.
This is a problem related to both the 68K and the PowerPC
implementation of the Palette Manager, although it could
only happen during a Transluscent drag.
- The memory allocation strategy used by
GetPictInfo could cause the routine to hang
if insufficient memory was available to allocate at least
one scan-line of a pixel map. GetPictInfo
has been corrected to return a memFullErr
when there is insufficient memory for it to run.
Power
Manager
The Power Manager provides facilities for
controlling power to the internal hardware devices in
battery-powered Mac OS-compatible computers.
PowerMgrLib has been moved to the data fork of the System
file.
Telephone Manager
The Telephone Manager works in conjunction
with the Communications Toolbox to provide telephone
services for the Mac OS, such as ISDN connectivity.
TelephoneLib 3.0 now resides in the System file's data
fork.
Thread
Manager
The Thread Manager provides multi-programming
services for use within application programs.
ThreadsLib 2.1.3 has been moved to the data fork of the
System file.
Window
Manager
The Window Manager provides facilities for
drawing and maintaining windows on the screen.
It was possible for GrayRgn to be allocated
in the current heap zone the first time
InitWindows was called, making it possible for
the GrayRgn to be allocated in the application
heap zone by an extension during the system startup
sequence. In this case, the region handle would be destroyed
after the startup sequence had completed, leaving
GrayRgn undefined. InitWindows now
takes care to allocate the GrayRgn in the
system heap zone only once, the first time it is called.
This problem may have occurred in conjunction with
extensions displaying windows at system startup.
|