2 Threadmain spawns two subprocesses, one
3 to read the mouse, and one to receive
4 timer events. The events are sent via a
5 channel to the main proc which prints a
6 word when an event comes in. When mouse
7 button three is pressed, the application
28 if((mfd = open("/dev/mouse", OREAD)) < 0)
29 sysfatal("open /dev/mouse: %r");
31 if(read(mfd, m, sizeof m) != sizeof m)
54 threadmain(int argc, char *argv[])
65 /* create mouse event channel and mouse process */
66 a[0].c = chancreate(sizeof m, 0);
67 proccreate(mouseproc, a[0].c, STACK);
69 /* create clock event channel and clock process */
70 a[1].c = chancreate(sizeof(ulong), 0); /* clock event channel */
71 proccreate(clockproc, a[1].c, STACK);
75 case 0: /*mouse event */
78 case 1: /* clock event */
82 sysfatal("can't happen");