From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <139f376dbb00f86c77be49c96b3abfc0@plan9.bell-labs.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] libthread help ... From: "Russ Cox" In-Reply-To: <5.2.0.9.0.20021231213353.00a88ec0@pop.noos.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: Tue, 31 Dec 2002 23:35:11 -0500 Topicbox-Message-UUID: 3a60e560-eacb-11e9-9e20-41e7f4b1d025 if you run acid -l thread, it loads some useful functions. one such function is "stacks()", which prints the stack for all the threads in all the procs of the program. if you run this on your program, you see (i've deleted all but the relevant lines): acid: stacks() ------ threadmain: 0x00022328 1 Rendezvous alt(tag(*148068=0) 0: send(channel(223368))) sendul(c=0x00036888,v=0x00000002) /sys/src/libthread/channel.c:231 called from threadmain+0x254 /tmp/a.c:106 ------ mouseproc: 0x000366c8 2 Rendezvous alt(tag(*240176=0) 0: send(channel(222792))) send(c=0x00036648,v=0x0003aab4) /sys/src/libthread/channel.c:209 called from _ioproc+0x149 /sys/src/libdraw/mouse.c:85 ------ 0x00036788 3 Rendezvous alt(tag(*244856=0) 0: send(channel(223048))) sendul(c=0x00036748,v=0x00000001) /sys/src/libthread/channel.c:231 called from clockproc+0x63 /tmp/a.c:25 ------ 0x000368c8 4 Rendezvous alt(tag(*249380=0) 0: send(channel(223304))) sendul(c=0x00036848,v=0x00000000) /sys/src/libthread/channel.c:231 called from menuhitproc+0xad /tmp/a.c:57 ------ the problem is that the menuhitproc and main are both reading from the mouse. main got a new mouse event to send to menuhitproc, and menuhitproc is trying to send its result to main at the same time. perhaps you should wait for the menuhitproc to send its result before waiting for more mouse ops. you could change a[0].op to CHANNOP after sending to menuhitproc and then change it back after getting the result. i don't see why it's a separate proc. you might want main not to stop processing clock ticks while you wait for the menu event, i guess, but even then you could do that with a thread rather than a proc. russ