Node:Synchronization, Next: Statistics Collection, Prev: Networks, Up: Top, Contents, Top


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.

Node:Early Int, Next: Int Time, Prev: Synchronization, Up: Synchronization, Contents, Top

Non-Causal Interrupt Checking

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.

Node:Int Time, Next: Basic Barrier, Prev: Early Int, Up: Synchronization, Contents, Top

Determining Interrupt Arrival Time

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.)


Function: Time intArrTime( void )
If an interrupt handler calls the function, returns the time at which the corresponding interrupt request arrived. Otherwise, returns zero.


See file `' 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.

Node:Basic Barrier, Next: ANL Barrier, Prev: Int Time, Up: Synchronization, Contents, Top

Basic Barrier

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'.

Function: void init_barrier( int procs )
Initialize barrier for procs processors.

The barrier is entered with a call to `barrier'.

Function: void barrier( void )
Enter the barrier. All but the last thread in may be suspended until exit time.

For example code, see the end of `'.

Node:ANL Barrier, Next: Semaphore, Prev: Basic Barrier, Up: Synchronization, Contents, Top

The ANL-Compatible Barrier

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 `' and the ANL documentation.

Node:Semaphore, Prev: ANL Barrier, Up: Synchronization, Contents, Top

Additional Semaphore Functions

Two additional semaphore functions have been added.

int: sem_IsLocked(Sem addr)
Returns non-zero if semaphore addr is locked.

int: sem_Wait(Sem addr)
Will block until semaphore addr is unlocked, but will not attempt to get the lock. It's possible that the lock can be acquired again before the function returns.