Semaphore.Mod 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. MODULE Semaphore;
  2. (* Copyright 2020 Arthur Yefimov
  3. This file is part of Free Oberon.
  4. Free Oberon is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Free Oberon is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Foobar. If not, see <http://www.gnu.org/licenses/>.
  14. *)
  15. IMPORT SYSTEM;
  16. CONST sizeOfSem = 320;
  17. TYPE
  18. Sem* = RECORD
  19. padding: ARRAY sizeOfSem OF CHAR
  20. END;
  21. TimeSpec* = RECORD
  22. END;
  23. PROCEDURE -AAIncludeSemaphoreh0* '#include "Semaphore/Semaphore.h"';
  24. PROCEDURE -Close*(VAR s: Sem): INTEGER
  25. "sem_close((sem_t *)s)";
  26. PROCEDURE -Destroy*(VAR s: Sem): INTEGER
  27. "sem_destroy((sem_t *)s)";
  28. PROCEDURE -GetValue*(VAR s: Sem; VAR value: INTEGER): INTEGER
  29. "sem_getvalue((sem_t *)s, (int *)value)";
  30. PROCEDURE -Init*(VAR s: Sem; a, b: INTEGER): INTEGER
  31. "sem_init((sem_t *)s, (int)a, (unsigned int)b)";
  32. PROCEDURE -Post*(VAR s: Sem): INTEGER
  33. "sem_post((sem_t *)s)";
  34. PROCEDURE -TryWait*(VAR s: Sem): INTEGER
  35. "sem_trywait((sem_t *)s)";
  36. PROCEDURE -Wait*(VAR s: Sem): INTEGER
  37. "sem_wait((sem_t *)s)";
  38. PROCEDURE -TimedWait*(VAR s: Sem; ms: INTEGER): INTEGER
  39. "my_sem_timedwait((sem_t *)s, (int)ms)";
  40. END Semaphore.