Previous Up Next
Down

HOST_NAME.net Logo
Use this link if you want more information about Open Source project support services.

This project's summary page on SourceForge.net.

Suggestions on how to improve this project are welcome here.

Status and Text Reference Coding

Background

Phase I – error indicators.

The errno global variable

The 'C' language and the Unix operating system (which is written in 'C') had their origins in a 16 bit environment.  In such an environment resources are very scarce and several decisions had to be made to minimize their usage.  One set of those decisions had to do with the reporting of errors.

Assembler code typically used the 'carry' indicator that is part of the machine state to indicate an error.  Using that convention, if there was an error, there was no usable result and the cause of the error could be returned through the channel normally used to return the result.  The 'C' language did not provide a way to access the 'carry' bit; another method of indicating errors had to be invented.

Rather than consistently returning a status indicator, like the 'carry' bit, a result was always returned and special values were reserved to indicate errors.  Specifically, the NULL pointer indicated an error when a pointer was normally returned, and a negative value was returned when the normal result was restricted to a non-negative number. 

Although the negative value convention allowed for reporting the cause of an error, the NULL pointer convention did not.  Another way of communicating the cause of an error was needed.  The error communication channel adopted was the global variable errno.  Widely shared global variables are a poor communication device because it is very easy to overwrite the information it contains before that information has reached its nominal destination.

Some other environments environments, especially 32 bit and larger environments, use a different scheme.  They consistantly return a status indicator in all cases and return other results to memory locations whose addresses are passed as parameters.  This project makes such a scheme easily accessable in 'C'.

HP's OpenVMS (aka DEC's VMS)

The VMS message/status code is a 32 bit unsigned integer structured as follows:

from ZK-1722-GE
3130 2928 2726 2524 2322 2120 1918 1716 1514 1312 1110 0908 0706 0504 0302 0100
Cntl Facility number Message number Sev

The purpose of each field is as follows:

Sev – Severity code
3 bits.  The values mean:
  1. Warning.
  2. Success.
  3. Error.
  4. Informational.
  5. Severe Error.
All other values are reserved and should not be used.  Special bits –
  1. Success/failure indicator:
    1. Failure.
    2. Success.

Message ID
13 bits.  A facility specific meaning or message identifier.

Facility ID
12 bits.  A number indicating the facility that produced the status code.  Special bits –
  1. Facility Identifier group:
    1. System facility (defined by the propriator. That is HP, COMPAQ or DEC).
    2. Customer's facility (which should be registered with the propriator).

Ctrl
4 bits.  Each bit has a meaning –
  1. Display state:
    1. Display needed.
    2. Display done.
The other bits are currently reserved and should be 0.

Microsoft's Windows event/status/error codes.

These Windows types are 32 bit unsigned integers structured as follows:

HRESULT aka SCODE
3130 2928 2726 2524 2322 2120 1918 1716 1514 1312 1110 0908 0706 0504 0302 0100
S M C N r Facility Code

The purpose of each field is as follows:

Code
16 bits.  The status code from the facility.  Special bits:
  1. Code category:
    1. System wide code.
    2. Facility specific code.

Facility
11 bits.  A registered identifier for the origin of the Code.

r – reserved.

N – NT map
1 bit.  Meaning:
  1. From other technology platforms.
  2. From NT platforms.

C – Facility category
1 bit.  Meaning:
  1. System facility.
  2. Customer facility.

M – NT severity modifier.
1 bit.  This bit combines with the S bit to produce the following values:
  1. Success.
  2. Informational.
  3. Warning.
  4. Error.

S – Severity
1 bit.  Meaning:
  1. Success.
  2. Error.

Discussion.

Both of these schemes reserve half the message space for the system propriator.  This is way out of balance.  Neither used anything like a significant fraction of the number of messages allocated to them.  For non-propriatary use, the distribution of control needs to be much more even handed.

Both schemes make it fairly easy to accidently code a 'FATAL Success' message.  To say that this can cause confusion is more than a minor understatement.  Fairly obviously the 'severity' code should be part of the message selection.

Phase II

[TBS]

References.

HP's OpenVMS (aka DEC's VMS).
Condition code structure.
$PUTMSG system service (almost at the end of the description).
Microsoft's Windows.
Event identifiers.
Windows Error codes (about a quarter of the way down from the top).
NT Windows Error codes.
Designing COM Interfaces (about a third of the way down from the top).

Phase II – status and other code translation to text.

[TBS]

NOTE

The information on this page is mainly historical.  It may provide some information that is useful but does not really fit into the Programmer's Guide.  It should not require much in the way of maintainance.


Work List (Mostly preperation for Phase II):

  • Find and document similar facilities on other platforms.
  • Add references to the other OpenVMS message handling services.
  • Check for similar message handling services in W32.
  • Check for similar POSIX services.

page top
Previous Up Next
Down