Advertisement
IvoB1n

ios_2_skoro_hotovy_projekt.h

Apr 20th, 2020
368
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <ctype.h>
  5. #include <fcntl.h>
  6. #include <unistd.h>
  7. #include <semaphore.h>
  8. #include <sys/mman.h>
  9. #include <sys/types.h>
  10. #include <sys/wait.h>
  11.  
  12. #define num_of_args 6
  13. #define int_base 10
  14.  
  15. #define IMM_NAME "IMM"
  16. #define J_NAME "JUDGE"
  17.  
  18. #define FILE_NAME "proj2.out"
  19. #define FILE_MODE "w"
  20.  
  21. #define J_ENTER_SEM "/sem1"
  22. #define J_IMMREG_SEM "/sem2"
  23. #define J_IMMEXITWAIT_SEM "/sem8"
  24. #define IMM_ENTER_SEM "/sem3"
  25. #define IMM_REG_SEM "/sem4"
  26. #define IMM_CONFWAIT_SEM "/sem5"
  27. #define IMM_EXITWAIT_SEM "/sem6"
  28. #define WRITE_TEXT_SEM "/sem7"
  29.  
  30.  
  31. #define OPENED 1
  32. #define CLOSED 0
  33.  
  34. sem_t *j_enter_sem;
  35. sem_t *j_immreg_sem;
  36. sem_t *j_immexitwait_sem;
  37. sem_t *imm_enter_sem;
  38. sem_t *imm_reg_sem;
  39. sem_t *imm_confwait_sem;
  40. sem_t *imm_exitwait_sem;
  41. sem_t *write_text_sem;
  42.  
  43.  
  44.  
  45. struct Params {
  46.     int PI;
  47.     int IG;
  48.     int JG;
  49.     int IT;
  50.     int JT;
  51. };
  52.  
  53. struct Actual_inf {
  54.     int PROCESS_ID;
  55.     int IMM_COUNT;
  56.     int IMM_W_CERT;
  57.     int NE;
  58.     int NC;
  59.     int NB;
  60. };
  61.  
  62. struct Actual_inf actual_inf;
  63. struct Actual_inf *mem = NULL;
  64.  
  65. int load_res();
  66.  
  67. int clean_res();
  68.  
  69. void random_sleep(int ms);
  70.  
  71. int params_check(struct Params *params, char *endptr_ig, char *endptr_jg, char *endptr_it, char *endptr_jt);
  72.  
  73. void immigrant_process(FILE *file, struct Params *params);
  74.  
  75. void judge_process(FILE *file, struct Params *params);
  76.  
  77. int main(int argv, char **argc);
Advertisement
RAW Paste Data Copied
Advertisement