TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Beard, Frank" <[log in to unmask]>
Thu, 20 Apr 2000 18:47:23 -0400
text/plain (1323 bytes) , garbage_collection.1.ada (489 bytes) , garbage_collection.2.ada (6 kB)
I wouldn't normally ask this question on this list,
but seeing how a number of the participants seem
to be instructors (and the general knowledge that
seems to be represented here), I would like some
opinions/clarifications of the following code that
uses a protected type within the body.

 <<garbage_collection.1.ada>>  <<garbage_collection.2.ada>>

This code is used by a number of our access type
based classes.  It runs for long periods of time then
suddenly we begin getting CONSTRAINT_ERROR
at the line:

"garbage_Collector := Next_Of(the_Item => garbage_Collector.all);"

inside the New_Item method of the protected type
(line 89).  I'm not sure of all of the ramifications of
what the LRM means by protected functions working
as READ_ONLY.  So, protected functions can be
called from within other protected function or protected
procedures, but a protected procedure cannot be
called from within a protected function.

So, I'm trying to figure out if I'm hitting some type of
timing problem where one task is freeing an object's
memory while another task is picking up memory for
the same type of object.  In other words, does a
protected function not block another task from calling
a protected procedure.  Should I change the New_Item
function to a procedure?

Anyway, take a look at the code (primarily the
Dispose_Item and the New_Item) and see if any
problems come to mind.