An option is provided for detecting too-early interrupts, and a function for returning interrupt arrival time. Two barriers are provided, one implements the ANL macros barrier, the other is a simple but more efficient barrier.
The system simulated by Proteus before version L3.11 can request an interrupt before the event causing the interrupt occurs, a possibly desirable feature not found in any existing computers. This condition will be trapped if the macro `TRAP_EARLY_INTERRUPT' is defined in file `lsu.param'. When the macro is defined an interrupt which occurs early results in a fatal error. There is no general way to delay the interrupt (thus avoiding the error).
Starting with version L3.11, interrupts never occur before their triggering events.
The function `intArrTime' returns the arrival time of the most recent interrupt. (Interrupt requests in Proteus, and in most other systems, are not always serviced immediately, so a handler cannot determine arrival time by examining CURRENTTIME.)
See file `genTest.ca' for an example of the function's use. It is also possible to get the arrival time of an interprocessor-interrupt message; see section Timing Messages.
The basic barrier implements a simple barrier. There must be exactly one thread per processor using the basic barrier. Further, the threads must use consecutive processor numbers starting with 0. The barrier is not named; there is only one instance that all must use. The barrier can safely be used in loops.
The barrier generates events if parameter `WATCH_BARRIER' is defined. The parameter can be found in file `conf.param' and can be set using the config program. An event is generated when a processor enters and exits the barrier. Graphs displaying barrier status have been included in the `Graphfile' for viewing with stats.
The barrier is implemented using a degree-four tree of counters. Except for the last thread in, threads entering the barrier will suspend. The last thread to enter the barrier will wake up other threads. The wakeups are propagated using the same tree.
The barrier calls are declared in `basic_barrier.h'.
The barrier is initialized with a call to `init_barrier'.
The barrier is entered with a call to `barrier'.
For example code, see the end of `basic_barrier.ca'.
Barrier functions implementing the barrier in the Argonne National Laboratory p4 Programming Systems are provided. The declarations are in file `proFun.h'. (If these functions are used the object code will have to be included in the userobj list, usually placed in file `UserMake'.)
These functions fully implement the ANL barriers, however the implementation is not particularly efficient. The barrier is implemented by using a single shared memory location to store a count, and other shared memory locations to store the lock status. This results in a very hot hot spot when more than a few threads are in the barrier.
For more details see files `proFun.h' and `proFun.ca' and the ANL documentation.
Two additional semaphore functions have been added.