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.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!apple!claris!peirce From: peirce@claris.com (Michael Peirce) Newsgroups: comp.lang.ada Subject: Re: Two questions Message-ID: <9274@claris.com> Date: 29 Mar 89 18:35:57 GMT References: <674@uva.UUCP> Reply-To: peirce@claris.com (Michael Peirce) Organization: Claris Corporation, Mountain View CA List-Id: >2. When a task has completed its execution, termination is delayed until all > dependent tasks have terminated (9.4.6). As a result, our program > fills up all memory with completed tasks unable to terminate. Why is > this? Can something be done about it (without altering task dependency)? > > >We have the impression that Ada was designed to deal with a small >number of large tasks, whereas we are trying to create a large number >of small tasks. Is this true? Does it matter? > The way we dealt with this problem was to reuse our tasks. We had a situation where we wanted to dispatch a handler task for each incoming request from the network. In Vax Ada, the tasks weren't removed from memory until after the program exited the scope of the task declaration. This meant that in our outter most scope, a terminated tasks' memory was never reclaimed. To solve this problem, we set up a task manager that kept a list of idle tasks and whenever a task was requested it would reuse one of these tasks first before creating a new one. Of course, each task ended up having some extra code at the beginning to handle initialization and some at the end to handle returning itself to the free list. This overhead was minimal though. With this type of scheme in place we were able to run our system for days or weeks at a time using "new" tasks for each message, but never running into memory usage problems. -- michael