12.3 User Mode Traps

Consider first of all a trap which is not generated as the result of the execution of a “trap instruction”. This is regarded as a probable error for which the operating system makes no provision apart from the possibility of a “core dump”. However the use program itself may have anticipated it and provided for it.

The way this provision is made and implemented is the subject of the next chapter. At this stage, the principal requirement is to “signal” that the trap has occurred.

2721:

A bus error has occurred while the system is in user mode. Set “i” to the value “SIGBUS” (0123);

2723:

The “break” causes a branch out of the “switch” statement to line 2818;

2733:

Apart from the one special case noted, the treatment of illegal instructions is the same at this level as for bus errors;

2739:
2743:
2747:
2796:

Cf. the comment for line 2721.

Note that cases “4+USER” (power fail) and
“7+USER” (programmed interrupt) are handled by the “default” case (line 2715).

2810:

This represents a case where operating system assistance is required to extend the user mode stack area.

The assembler routine “backup” (1012) is used to reconstruct the situation that existed before execution of the instruction that caused the trap.

“grow” (4136) is used to do the actual extension.

The procedure “backup” is non-trivial and its comprehension involves a careful consideration of various aspects of the PDP11 architecture. It has been left for the interested reader to pursue privately.

As noted for the PDP11/40, “backup” may not always succeed because the processor does not save enough information to resolve all possibilities.

218:

Call “psignal” (3963) to set the appropriate “signal”. (Note that this statement is only reached from those cases of the “switch” which included a “break” statement.);

2821:

“issig” checks if a “signal” has been sent to the user program, either just now or at some earlier time and has not yet been attended to;

2822:

“psig” performs the appropriate actions. (Both “issig” and “psig” are discussed in detail in the next chapter.);

2823:

Recalculate the priority for the current process.