Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <errno.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/wait.h>
  6. #include <sys/stat.h>
  7. #include <sys/ipc.h>
  8. #include <sys/shm.h>
  9. #include <pwd.h>
  10. #include <stdlib.h>
  11. #include <string.h>
  12. #include <time.h>
  13. #include <sys/shm.h>
  14. #include <sys/sem.h>
  15. #include <sys/msg.h>
  16. #include <stdio.h>
  17. #include <sys/shm.h>
  18. #include <sys/sem.h>
  19.  
  20. int main()
  21. {
  22. int semid;
  23. struct sembuf op;
  24. semid = semget(0x234, 1,IPC_CREAT | 0700);
  25. if (semid == -1)
  26. {
  27. perror("semget");
  28. exit(1);
  29. }
  30. if(semctl(semid, 0, SETVAL, 1)!=0)
  31. perror("semctl: ");
  32. puts("Wystartowal program A");
  33. puts("-----Pierwszy etap------");
  34. op.sem_flg = 0;
  35. op.sem_num = 0;
  36. op.sem_op = 0;
  37. if (semop(semid, &op, 1) == -1)
  38. {
  39. perror("semop");
  40. exit(1);
  41. }
  42. sleep(1);
  43. puts("-----Drugi etap----------");
  44. op.sem_flg = 0;
  45. op.sem_num = 0;
  46. op.sem_op = 0;
  47. if (semop(semid, &op, 1) == -1)
  48. {
  49. perror("semop");
  50. exit(1);
  51. };
  52. puts("KONIEC A");
  53. return(0);
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement