When to run "exit" code 
Author Message
 When to run "exit" code

I'm developing a system that requires a lot of dynamic storage manipulation.
For the first go, I'm keeping it simple by just using a generic package
that keeps a list of freed objects and allocates from that list or uses
NEW if the free list is empty (i.e. Booch's Storage_Manager_Sequential).

Since I'm in the prototype stage, I'd like to keep some statistics on how
big the free list gets, how many total allocations occured, etc.  My problem
is how to report this information when the application exits.  My wish-ful
solution would be to keep the statistics in the body and at exit time, print
them to a file.  The rub is how do I know that it is time to exit?  Is
there a CLEANUP begin/end equivalent to package elaboration?  Since the
storage allocator is buried deep inside package bodies, there is no
access to it from the outside (besides allowing a clean design, the
production version will not waste time with statistics, so the design
should not require this).

Some of the ideas I've thought about (but not tried to implement) are:

1) Start a task with a very low priority that will only run when the
   main task has completed.

2) Start a task that awakes every second or two to check if a file is
   present, and if so, print its statistics.  This requires the main
   task to create a file just before it is finished (i.e. a global
   flag that doesn't require WITH'ing).  However, the generic would
   have to be written so that separate instantiations would
   synchronously update the log file (or create unique log files).

3) Have a small package that keeps a global variable flag that is
   WITH'ed by the generic body and the main task.  This is basically
   number 2, but without using a file as a flag.  Same problem with
   synchronizing multiple instantiations.

Any help would be greatly appreciated.

Stuart.



Sun, 08 Nov 1992 20:40:20 GMT  
 When to run "exit" code

Re: writing "exit-time code" in Ada83

Using priority to accomplish "exit code" (a.k.a. finalization)
is non-portable, but will probably work in most mono-processor
implementations.  I have seen a few other clever tricks, but
have unfortunately forgotten them (there might be someone
out there on the net with some clever scheme).

I know that a number of compilers have a library-level cleanup
mechanism, used by their own RTS to close files, etc.  You might
be able to plug into one of those (still non-portable) mechanisms.

In any case, general "finalization" emerged quite early
in the Ada9X process as a useful enhancement to Ada.  We are considering
it quite seriously.  When combined with exception handling,
abort, terminate, etc., it is far from trivial to define
and efficiently implement, but we are trying...  

C++ has it now, but alas, they
don't have those other things (exceptions, etc.).  Now that
Bjarne Stroustrap is considering adding exceptions to C++, I am sure
he will have some interesting things to say about the interactions
with finalization (aka "destructors" in C++).

S. Tucker Taft
Ada9X Mapping/Revision Team
Intermetrics, Inc.
Cambridge, MA  02138



Wed, 11 Nov 1992 00:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

2. What replaces "EXIT"?

3. problem with "exiting".........

4. Py_Exit if "exit" not required

5. Changing "exit" command in Tcl

6. QUESTION: TK "exit" window control

7. Q: "on exit" processing

8. Disabling "X" exit button on toplevels

9. catch: removing "child process exited abnormally"

10. cgi-bin "exec": error waiting for process to exit: No child processes

11. Unexpected behavior from $interp eval "exit"

12. Embedding Tcl -- "exit" and proper cleanup

 

 
Powered by phpBB® Forum Software