From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,2afbf99c1f65cbe X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.73.228 with SMTP id o4mr1701099pav.32.1344324957320; Tue, 07 Aug 2012 00:35:57 -0700 (PDT) Path: p10ni57pbh.1!nntp.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Sharing a socket connection Date: Tue, 31 Jul 2012 12:28:27 +0200 Organization: cbb software GmbH Message-ID: <16x1nvmt3gznc$.15s7zskookawr$.dlg@40tude.net> References: <87hasofgwa.fsf@adaheads.sparre-andersen.dk> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 X-Received-Bytes: 2556 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-07-31T12:28:27+02:00 List-Id: 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