Advertisement
Guest User

macarenaaaaaa

a guest
Apr 16th, 2014
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/ipc.h>
  3. #include <sys/sem.h>
  4.  
  5. int sem_id;
  6.  
  7. int main(int argc, char *argv[])
  8. {
  9.  
  10.  if (argc != 2) {
  11.         printf("Wrong number of parameters\n");
  12.         exit(1);
  13.     }
  14.  
  15. int N = atoi(argv[1]);
  16. int i;
  17. pthread_t th[1000];
  18.  
  19. for (i=0; i<N; i++)
  20.   if (pthread_create(&th[i], NULL, (void* (*) (void*)) increment, (void*) i) != 0) {
  21.     perror("Cannot create threads");
  22.     exit(1);
  23.   }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement