next up previous 252
Next: F77_ISTRUE - Is this the FORTRAN logical value true?
Up: Full Description of F77 Macros
Previous: F77_ISFALSE - Is this the FORTRAN logical value false?


F77_LOCK - Prevents code from being run simultaneously in two separate threads

Description:
Any C code that may need to be used in a threaded context should use this macro should to prevent Fortran code being run simultaneously in two separate threads, with consequent danger of unsynchronised memory access. The macro locks the global CNF mutex, then executes the code specified in the argument, and then unlocks the mutex. If the mutex is currently locked by another thread (e.g. due to the use of F77_LOCK in the other thread), then the calling thread blocks until the other thread releases the mutex.

Invocation:
F77_LOCK(code)

Arguments:

code
Any arbitrary C code. Typically, this will be an invocation of a Fortran subroutine.

Examples:

F77_LOCK( result = F77_CALL(sim)( nel, data, status ); )

Notes:
This macro invokes the cnfLock and cnfUnlock functions to lock and unlock the global mutex.


next up previous 252
Next: F77_ISTRUE - Is this the FORTRAN logical value true?
Up: Full Description of F77 Macros
Previous: F77_ISFALSE - Is this the FORTRAN logical value false?

CNF and F77 Mixed Language Programming -- FORTRAN and C
Starlink User Note 209
P.M. Allan
A.J. Chipperfield
R.F. Warren-Smith
P.W. Draper
18 April 2008
E-mail:starlink@jiscmail.ac.uk

Copyright © 2013 Science and Technology Facilities Council