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: 103376,19ad05fdbf4e671f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.cw.net!cw.net!news-FFM2.ecrc.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Deallocating records with task type fields. Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1134168554.826805.70690@g49g2000cwa.googlegroups.com> <1vb61utj75dws.gjbmfyig7vzz.dlg@40tude.net> <1134274006.711602.173280@g43g2000cwa.googlegroups.com> Date: Sun, 11 Dec 2005 12:50:18 +0100 Message-ID: <1bjubyn0kl3cr.1l53b31tl59vw.dlg@40tude.net> NNTP-Posting-Date: 11 Dec 2005 12:50:22 MET NNTP-Posting-Host: c6728dad.newsread2.arcor-online.net X-Trace: DXC=Di;KCSUC0@UXNWN: On 10 Dec 2005 20:06:46 -0800, Gene wrote: > Many thanks. I certainly could have picked a better of example that > Port for data. > > In fact the real environment record also has a protected output queue > with procedures to get data from the queue that the Listener has placed > there. That's the interesting case because other tasks need to call > functions that can touch the queue. I couldn't see a good way to > declare the queue on the task stack and yet allow other tasks to get > things from it. > > So before the current method I indeed implemented the shared queue by > passing it to the Listener with a discriminant (your 2.). Also tried a > Start entry (your 3.). In all the method above is by far the cleanest > because the whole Listener is a single type that acts like a functional > closure. This matter of handling deallocation when the executive task > exits is the only rough edge. > > As the name implies, the application is a TCP network listener in a > multi-node graphics application. Listeners are allocated as needed and > exit when their corresponding connections are terminated, either > normally or due to an error condition. When this happens, we want the > Listener to arrange for its own deallocation. > > Currently I just have the Executive put its enclosing Listener on a > system-wide "dead listener" queue. There is a procedure that traverses > the queue to deallocate any listeners whose executive tasks have indeed > terminated. This is called whenever a new Listener is allocated. This > works fine (although it needs Real Time Extensions). I wondered if > there was a simpler way. > > In fact just for fun I also tried having the Listener call > Unchecked_Deallocation itself just before exiting (i.e. the task was > deallocating its own context!). And with GNAT running under both > Solaris and Windows it never caused a problem. Yes, AFAIK it works with GNAT. But the real question is if a listener can be accessed outside the task, then there is a danger that the task could prematurely deallocate it. Thus there must be somebody responsible for the life span of listener. Your variant with "dead listener" queue is nothing but a GC. One could also use reference counting GC. In any case it is global GC, which is responsible. The problem with this is what is a listener object worth when the task is dead? If a task life span is shorter then this state change should be visible for users of listeners. This devaluates the idea of GC. If users are aware of state change, they could also take care of deallocation of listeners. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de