mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-23 12:48:40 -05:00
55 lines
1.2 KiB
Fortran
55 lines
1.2 KiB
Fortran
|
subroutine cs_init
|
||
|
character*12 csub0
|
||
|
common/mtxcom/ltrace,mtx,mtxstate,csub0
|
||
|
ltrace=0
|
||
|
mtxstate=0
|
||
|
csub0='**unlocked**'
|
||
|
call fthread_mutex_init(mtx)
|
||
|
return
|
||
|
end subroutine cs_init
|
||
|
|
||
|
subroutine cs_destroy
|
||
|
character*12 csub0
|
||
|
common/mtxcom/ltrace,mtx,mtxstate,csub0
|
||
|
call fthread_mutex_destroy(mtx)
|
||
|
return
|
||
|
end subroutine cs_destroy
|
||
|
|
||
|
subroutine th_create(sub)
|
||
|
call fthread_create(sub,id)
|
||
|
return
|
||
|
end subroutine th_create
|
||
|
|
||
|
subroutine th_exit
|
||
|
call fthread_exit
|
||
|
return
|
||
|
end subroutine th_exit
|
||
|
|
||
|
subroutine cs_lock(csub)
|
||
|
character*(*) csub
|
||
|
character*12 csub0
|
||
|
integer fthread_mutex_lock,fthread_mutex_trylock
|
||
|
common/mtxcom/ltrace,mtx,mtxstate,csub0
|
||
|
n=fthread_mutex_trylock(mtx)
|
||
|
if(n.ne.0) then
|
||
|
! Another thread has already locked the mutex
|
||
|
n=fthread_mutex_lock(mtx)
|
||
|
iz=index(csub0,' ')
|
||
|
if(ltrace.ge.1) print*,'"',csub,'" requested mutex when "', &
|
||
|
csub0(:iz-1),'" owned it.'
|
||
|
endif
|
||
|
mtxstate=1
|
||
|
csub0=csub
|
||
|
if(ltrace.ge.3) print*,'Mutex locked by ',csub
|
||
|
return
|
||
|
end subroutine cs_lock
|
||
|
|
||
|
subroutine cs_unlock
|
||
|
character*12 csub0
|
||
|
common/mtxcom/ltrace,mtx,mtxstate,csub0
|
||
|
if(ltrace.ge.3) print*,'Mutex unlocked,',ltrace,mtx,mtxstate,csub0
|
||
|
mtxstate=0
|
||
|
call fthread_mutex_unlock(mtx)
|
||
|
return
|
||
|
end subroutine cs_unlock
|