Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Bart Smaalders <barts@eng.sun.com>
Subject: Re: pthreads and sockets
Date: 1996/12/06	[thread overview]
Message-ID: <32A8A6A8.C1@eng.sun.com> (raw)
In-Reply-To: 589ceq$g76$1@asgard.sprintlink.co.za


Take a look at name_cache.c for an alternative approach in our
book, "Programming with Threads".  The examples may be downloaded
from:

http://www.Sun.COM:80/smi/ssoftpress/threads/index.html

Spawning 1000 threads may make sense if you have a really big MP
and the duty cycle (%active time) of each thread is really high.
For most systems where clients are idle most of the time (due to 
think time, etc), dispatching each actual request to a thread
will result in less resource consumption, better cache behavior, 
etc.

For example, supppose in the limiting case only one client request
was active at a time.  Using separate threads would force each 
thread stack to be brought into the cache (or worse, into memory),
while simply using a LIFO queue of service threads would produce
much better performance.

In general, controlling the amount of concurrency using a workpile
style technique results in more easily tuned applications, and ones
that behave more reasonably under unreasonable loads.

- Bart

philip Shearer wrote:
> 
> I am assessing the possibility of replacing a network communications
> subsystem with a TCP/IP implementation using pthreads. It is the
> first pthreaded application I have attempted , but I have a lot
> of experience of this type of application on various UNIX systems
> using sockets and fork(ing).
> 
> At the moment the sub-system runs as a server on VMS and a client
> on MS-Windows using UDP on one PORT. Built into the comms layer is
> an in-house reliable connection mechanism between the VMS server
> MS-Windows clients.
> 
> The current sub-system works for about 550 connections but it is
> starting to become flaky as more clients are added.
> 
> The development (of the server software) will be done on Solaris
> x86 V 2.5.0 and Digital UNIX 4.0.
> 
> Ideally the server code should be portable to a VMS platform.
> 
> Is is there anything that we need to do to the kernels of the
> 3 systems to allow for 1000 TCP connections?
> 
> Is there any software on the Net which does this task or
> something similar.
> 
> If not then at the moment I envisage having :
> 
>    One thread accepting connections and creating one new thread
>    per connection. (Accepter)
> 
>    One thread read-blocking on the each socket connection. Each
>    thread will write to an internal IPC that is connected to the
>    main application.(Reader)
> 
>    One thread will read from an internal IPC to receive processed
>    messages from the main application. (Dispatcher)
> 
>    One thread per-connection which will block waiting for the
>    Dispatcher to send it a message with it will send out onto
>    the network. (Writer)
> 
> Is there a simple method by which the Dispatcher can multiplex
> to the correct Writer (assuming that any info needed to do this
> can be prefixed to the outgoing message by the main application)
> Or will I be forced to implement some sort of structure/lookup table
> containing a mutex lock for each Writer?
> 
> Is there a better way to write this sort of code?
> 
> --
> Regards Philip Shearer
> 
> eMail: philips@asiatech.co.za
> Tel  +27 (0)11 784 8925
> Fax  +27 (0)11 784 8919

-- 
Bart Smaalders			Solaris Clustering	SunSoft
barts@cyber.eng.sun.com		(415) 786-5335		MS UMPK17-301
http://playground.sun.com/~barts			2550 Garcia Ave
							Mt View, CA 94043-1100



  reply	other threads:[~1996-12-06  5:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-06  5:00 pthreads and sockets philip Shearer
1996-12-06  5:00 ` Bart Smaalders [this message]
1996-12-06  5:00 ` Bil Lewis
1996-12-09  5:00 ` Thilo Kielmann
1996-12-13  5:00   ` New version of ACE available Douglas C. Schmidt
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox