Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. // add even messages to file F1
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include "shared.h"
  6. #include "message.h"
  7. int main(){
  8.  
  9.     common *msg; int i;
  10.     msg = (common *)getmem(615621961);
  11.    
  12.     sem_t full  = sem_init(615621962);
  13.     sem_t empty = sem_init(615621963);
  14.        
  15.     FILE *fp = fopen("./F1.txt", "w");
  16.    
  17.  
  18.         for(i=1; i<30; i++){
  19.            
  20.             PS(full);
  21.            
  22.             if(msg->number%2==0){
  23.             fprintf(fp,"%s", msg->name);
  24.             fprintf(fp,"\n");      
  25.         }
  26.        
  27.         VS(empty);
  28.    
  29.     } //end i<30
  30.     fclose(fp);
  31.   return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement