From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Sharing a socket connection
Date: Tue, 31 Jul 2012 12:28:27 +0200
Date: 2012-07-31T12:28:27+02:00 [thread overview]
Message-ID: <16x1nvmt3gznc$.15s7zskookawr$.dlg@40tude.net> (raw)
In-Reply-To: 87hasofgwa.fsf@adaheads.sparre-andersen.dk
On Tue, 31 Jul 2012 10:56:21 +0200, Jacob Sparre Andersen wrote:
> We are working on a system where a number of Ada tasks are going to
> share a single socket connection to a server [1].
>
> The socket connection is bidirectional with requests sent from a client
> followed by corresponding responses from the server. Each client should
> only get responses to its own requests.
This sort of multiplexing will be extremely slow. Basically you block
communication until server respond.
> Our current approach is to encapsulate the socket in a package, and use
> a mutex [2] to lock the socket during an entire
> send-request-get-response operation.
>
> Greetings,
>
> Jacob
>
> [1] The rationale for this is that the individual tasks only are
> expected to use the server sporadically, and that letting each task
> have its own connection may use too many limited resources on the
> server.
>
> [2] Do the standard libraries include a mutex (I have a vague
> recollection of having seen one, but can't find it), or should we
> just implement it ourselves (or use the one in "Simple components
> for Ada").
If you look at the implementation there, it is quite simple.
My primary concern would making it full duplex multiplexed. Because
half-duplex communication is really one of the major performance killers.
I would consider a request [protected] object queued to a dedicated task
doing I/O. The object would be waitable for the task that queued it. Which
is basically how OS drivers work.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2012-08-07 7:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-31 8:56 Sharing a socket connection Jacob Sparre Andersen
2012-07-31 10:18 ` Niklas Holsti
2012-07-31 10:28 ` Dmitry A. Kazakov [this message]
2012-07-31 11:50 ` Jacob Sparre Andersen
2012-07-31 12:09 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox