TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Ruud Senden
from: Peter Fitzsimmons
date: 1994-12-29 16:49:00
subject: Unnamed pipes

RS> I'm writing a program with two threads. There are two 
 RS> unnamed pipes, created with DosCreatePipe(), to 
 RS> communicate between the threads. 

 RS> One of the pipes is used to send commands from the 
 RS> main thread to the other thread, the other one to send 
 RS> status information from the other thread to the main 
 RS> thread.

This is a very odd use for a pipe.  Unnamed pipes were provided primarily
for separate _processes_ to send data to each other,  ala Unix stuff.

They are slow and cumbersome in the eyes of a Thread,  who has more
flexible/powerful/faster IPC mechanisms available.  In your case,  I would
have used queues (see DosCreateQueue()).

 RS> Since I also have to do other things in both threads, 
 RS> I don't want the DosRead()-call to block.

If you ever find yourself saying a thread has "other things to
do" it means you need another thread!   When nothing is happening, 
ALL threads should be blocked on a system call.

For the same reason,  DosReadQueue() should always be called with DCWW_WAIT
(wait for an element to be placed in the queue).  If you find yourself
wanting to call it with DCWW_NOWAIT,  you have made a design error
somewhere.

There is a DosPeekQueue() and DosQueryQueue() function,  but no one should
ever use them for the reasons just stated...

Pete's Thread Axiom:  A threads primary purpose is to do nothing very well.


--- Maximus/2 2.01
* Origin: Sol 3/Toronto (905)858-8488 (1:259/414)
SEEN-BY: 12/2442 620/243 624/50 632/348 640/820 690/660 711/409 410 413 430
SEEN-BY: 711/807 808 809 934 942 949 712/353 515 713/888 800/1 7877/2809
@PATH: 259/414 400 99 250/702 3615/50 229/2 12/2442 711/409 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.