2 * cc evfilt_user.c -pthread -I/usr/src/sys/ -o /tmp/evfilt_user
12 static void *domaster(void *arg
);
13 static void *doslave(void *arg
);
16 main(int ac
, char **avj
)
25 EV_SET(&kev
, 1, EVFILT_USER
, EV_ADD
|EV_CLEAR
, 0, 0, 0);
26 r
= kevent(fd
, &kev
, 1, NULL
, 0, NULL
);
27 printf("r = %d\n", r
);
28 pthread_create(&td1
, NULL
, domaster
, (void *)(intptr_t)fd
);
30 pthread_create(&td2
, NULL
, doslave
, (void *)(intptr_t)fd
);
31 pthread_join(td1
, NULL
);
32 pthread_join(td2
, NULL
);
39 int fd
= (int)(intptr_t)arg
;
42 printf("master running\n");
44 EV_SET(&kev
, 1, EVFILT_USER
, 0, NOTE_TRIGGER
, 0, 0);
45 r
= kevent(fd
, &kev
, 1, NULL
, 0, NULL
);
46 printf("issued trigger %d\n", r
);
57 int fd
= (int)(intptr_t)arg
;
60 printf("slave running\n");
62 r
= kevent(fd
, NULL
, 0, &kev
, 1, NULL
);
63 printf("received %d\n", r
);
65 EV_SET(&kev, 1, EVFILT_USER, EV_CLEAR, 0, 0, 0);
66 r = kevent(fd, &kev, 1, NULL, 0, NULL);