Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- int status, i;
- pthread_t tr[NO_RECIEVERS], tw[NO_SENDERS], bd;
- i=1;
- for(i=1; i<=NO_SENDERS; i++) {
- pthread_create(&tw[i-1], NULL, writer, &i);
- }
- for(i=1; i<=NO_RECIEVERS; i++) {
- printf("%dn", i);
- pthread_create(&tr[i-1], NULL, reader, &i);
- }
- pthread_create(&bd, NULL ,daemon_thread, NULL);
- for(i=1; i<=NO_SENDERS; i++) {
- pthread_join(tw[i-1], NULL);
- }
- for(i=1; i<=NO_RECIEVERS; i++) {
- pthread_join(tr[i-1], NULL);
- }
- pthread_join(bd, NULL);
- return 0;
- }
- void* reader(void *val) {
- int ret, fd, id;
- struct mssg data;
- id = *(int*)val;
- printf("id: %d %dn", id, *(int*)val);
- while(1) {
- ...
- id: 1 1
- ...
- id: 2 2
- ...
- id: 1 1
- ...
- id: 1 1
- ...
- 2
- id: 2 2
- ...
- id: 4 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement