next up previous contents index
Next: File System Up: Topaz Operating System Interface Previous: Topaz Operating System Interface

Reporting Errors

      A UNIX system call reports an error by storing an error number in the variable errno and then returning the value -1. The variable errno causes a problem for a multithreaded client, since different values could be assigned due to concurrent system calls reporting errors. (Another source of confusion results from system calls that can return -1, e.g., nice or ptrace.)

    A workable but clumsy solution would be for every system call that could report an error to return an error code via a result parameter. We chose to use Modula-2+ exceptions instead. Exceptions have the advantage over return codes that they can't be accidentally ignored, because an exception for which no handler exists results in abnormal termination of the program.[*] Exceptions are handled by enclosing a statement sequence that could raise an exception with a TRY ... EXCEPT statement.

        A Modula-2+ procedure declaration may include a RAISES clause enumerating the exceptions the procedure may raise. The declaration of an exception may include a parameter, allowing a value to be passed to the exception handler. Most procedures in the Topaz operating system interface can raise the exception Error, which is declared with a parameter serving as an error code, analogous to the UNIX error number. Topaz defines the exception Alerted for reporting thread alerts (discussed in Section 3.3). Each procedure in the Topaz operating system interface that may do an unbounded wait includes Alerted in its RAISES clause. As described in Section 4.3, Topaz also uses exceptions to report synchronous events such as hardware traps.


next up previous contents index
Next: File System Up: Topaz Operating System Interface Previous: Topaz Operating System Interface
Paul McJones
8/28/1997