[Omp] omp_set_lock/omp_test_lock
Daniel Franke
franke.daniel at gmail.com
Tue Nov 21 13:57:17 PST 2006
The specs v2.5 state:
3.3.5 omp_test_lock and omp_test_nest_lock
[...]
Constraints on Arguments
A lock accessed by either routine must not be in the uninitialized state.
A simple lock accessed by omp_test_lock which is in the locked state must
not be owned by the thread executing the routine.
For clarification: if one attempts to set the same simple lock twice, a
deadlock occurs as one thread waits for itself to release the lock. If a
thread only tests a lock it already holds, there should be no such problem?
What kind of error should occur in the program below?
Thanks
Daniel
$> cat main.f90
PROGRAM main
USE OMP_LIB
INTEGER(omp_lock_kind) :: lock
CALL omp_init_lock(lock)
WRITE(*,*) omp_test_lock(lock) ! set lock, expected: 'T'
WRITE(*,*) omp_test_lock(lock) ! test lock, expected: 'F'
CALL omp_unset_lock(lock)
CALL omp_destroy_lock(lock)
END PROGRAM
$> gfortran-4.3 -g -Wall -fopenmp main.f90 && ./a.out
T
F
$> ifort-9.0 -openmp -g -warn all -check all main.f90 && ./a.out
T
F
More information about the Omp
mailing list