Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Threema/Threema/RootCoordinator/   (Threema ©)  Datei vom 26.9.2026 mit Größe 6 kB image not shown  

Quellcode-Bibliothek phil.cob   Interaktion und
PortierbarkeitCobol

 

        identification division.
        program-id. philosopher.
        author. NN.
      * dining philosophers
        data division.
         working-storage section.
          78 N    value 5.
          01 tmp1   pic 9(4).
          01 tmp2   pic 9(4).
          01 i1     pic 9(4).
         linkage section.
          01 i      pic 9(4).
          01 semid  pic 9(4).
        procedure division using i semid.
         perform until false
           display "philosopher "i" thinks"
           call semwait using semid i 1
           compute i1 = i+1 
           compute tmp1 = function mod(i1,N)
           move 1 to tmp2
           call semwait using semid tmp1 tmp2
           display "philosopher " i " eats"
           call semsignal using semid i tmp2
           call semsignal using semid tmp1 tmp2
         end-perform  
        end-Program philosopher. 

        identification division.
        program-id. main.
        author. NN.
        data division.
         working-storage section.
          78 N    value 5.
          01 i      pic 9(4).
          01 semid  pic 9(4).
        procedure division.
         compute semid = function semget(IPC-PRIVATE,N,0600)
         perform varying i from 0 until i>=N
           call semsetval using semid i 1
         end-perform
         perform varying i from 0 until i>= N-1 
           compute pid=function fork()
           if pid = 0 then
             call philosopher using i semid
             call philosopher using i semid
         end-perform
        end-Program main.

Messung
CHZG
819810093

¤ Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.0.0Bemerkung:  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-11-23) ¤

*Eine klare Vorstellung vom Zielzustand