C OOODDL    SOURCE    PV090527  26/04/24    08:23:02     12524          
        subroutine oooddl(pseg,harg)
C
C  verifier qu'on n'est pas en deadlock. Sinon erreur
C
-INC IOODES
-INC IOOADR
-INC IOOWCOM
-INC IOOUNIT

      character*(*)  harg
      character*(80) ooo_ha(128)
      INTEGER ooo_wa(128),ooo_w2(128),ooo_ka(128),ooo_nbthr,pseg
      SAVE    ooo_wa    ,ooo_w2    ,ooo_ka    ,ooo_nbthr,ooo_ha

C     On met un SEGMENT pour avoir OOTHRD (le traducteur s'en charge)
      SEGMENT ISEG(0)

      nth=oothrd
      ooo_w2(nth+1)=pseg
      ooo_wa(nth+1)=pseg
      ooo_ha(nth+1)=harg
      ooo_ka(nth+1)=KASINS

      do 100 jth=0,ooo_nbthr-1
        if (ooo_wa(jth+1).eq.0) return
 100  continue

      do 220 ith=0,ooo_nbthr-1
        iseg=ooo_wa(ith+1)
        hdia=ooo_ha(ith+1)
        ldia=len(hdia)
        KASINS=ooo_ka(ith+1)
        write (ooo_ha(ith+1),'('' rw: '',i6,'' ro: '',2i6,
     &                         '' ASSISTANT '',i3)')
     &         mdrw(iseg),mdro1(iseg),mdro2(iseg),ith
        call oooerr (iseg,2,'DEADLOCK DETECTEE '//ooo_ha(ith+1))
 220  continue
      stop

C     on note qu'on n'est plus en attente
      entry oooudl
        nth=oothrd
C        iseg=ooo_wa(nth+1)
        ooo_wa(nth+1)=0
        ooo_w2(nth+1)=0
      return

C     initialisations au demarrage
      entry oooidl
C      write (JLST,*) ' oooidl appele'
       do 300 ith=0,127
         ooo_wa(ith+1)=0
         ooo_w2(ith+1)=0
         ooo_ha(ith+1)=' '
 300   continue
       ooo_nbthr=1
       return

C     test si ce segment est en attente
      entry oootdl(pseg,ifla)
      do jth=0,ooo_nbthr-1
        if (ooo_w2(jth+1).eq.pseg) goto 170
      enddo
      ifla=0
      return
 170  continue
      ifla=1
      return

C     sur un segdes, on signal le wait parti. Si le thread est bloque en attente du global mutex, il ne le fera pas lui meme
      entry ooosdl(pseg)
      do 400 ith=0,ooo_nbthr-1
       if (ooo_wa(ith+1).eq.pseg) ooo_wa(ith+1)=0
 400  continue
      return

C     nombre de thread
      entry ooondl(nthr)
        ooo_nbthr=nthr+1
      end
 
