Advertisement
Guest User

Untitled

a guest
Oct 13th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. // threads
  2. pthread_t threads[map->n_thread];
  3. int id_thread[map->n_thread];
  4.  
  5. id_thread[0] = 0;
  6.  
  7. if (pthread_create(&threads[0],NULL,scheduler, &id_thread[0]) != 0)
  8. perror("Error creating scheduler");
  9.  
  10. for(i=1;i<map->n_thread;i++){
  11. id_thread[i] = i;
  12. if (pthread_create(&threads[i],NULL,worker,&id_thread[i]) != 0) //worker -> função que as threads vão fazer
  13. perror("Error creating threads");
  14. }
  15.  
  16. for(i=0;i<map->n_thread;i++){
  17. pthread_join(threads[i],NULL);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement