[LCP]design issues

Paul Gearon pag at pisoftware.com
Thu Aug 28 07:24:02 UTC 2003


Kurt Mueller wrote:
> On Wednesday, August 27, 2003, at 11:46 AM, mehul radheshyam choube wrote:
> 
>>     i am going to develop a server program for linux platform. the
>> scenario is of One Server - Multiple Clients. which of the following
>> technology be used - pipes, FIFO, Message Queues or threads? which one is
>> the best/widely used?
> 
> 
> I suppose you will run this on a UNIX/UNIX-like system.
<description removed>
> We have no experience in threads.

Just to add a note about threads... unless you have a very good reason 
for doing so, I'd steer clear of them for several reasons.

1. Synchronization is not as simple between threads as it is with the 
various forms of IPC.  IPC has well defined events which occur (eg. data 
available on a pipe) and which don't necessarily have to be actively 
listened for when they go off (eg. read() can happen any time after the 
data is available).

2. Since all memory is shared between threads it is possible to have 
interactions betweens the clients and the server that you weren't 
expecting.  You basically need to lock ALL memory accesses which are not 
on the stack.

3. Launching a new client requires a special interface into the 
application... possibly with IPC which you were trying to avoid in the 
first place.

4. There is also a lack of robustness for when things go wrong in a 
single thread.  A segfault can bring the entire app down.

5. The most compelling reason is that you reduce the modularity of your 
system.  The above points are all a part of this problem, but there are 
other hassles as well, such as increased complexity, and a greater 
likelihood of bugs.

Threads are very useful and certainly have their place, but if IPC is an 
option for you then it's highly unlikely that threads will be useful to you.

-- 
Regards,
Paul Gearon

Software Engineer                Telephone:   +61 7 3876 2188
Plugged In Software              Fax:         +61 7 3876 4899
http://www.PIsoftware.com        PGP Key available via finger

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")





More information about the linuxCprogramming mailing list