[Oberon] Oberon for a C++ user.

Andreas Pirklbauer andreas_pirklbauer at yahoo.com
Fri Oct 7 00:30:08 CEST 2016


Solution #2 ('check for references and don't unload if there are any') is implemented in Experimental Oberon, eliminating inadvertent references to unloaded modules via installed procedures.

Skulski, Wojciech skulski at pas.rochester.edu  <mailto:oberon%40lists.inf.ethz.ch?Subject=Re:%20Re%3A%20%5BOberon%5D%20Oberon%20for%20a%20C%2B%2B%20user.&In-Reply-To=%3CCY1PR07MB22136A0301D06E433CEF119EFFC70%40CY1PR07MB2213.namprd07.prod.outlook.com%3E>
Thu Oct 6 21:22:59 CEST 2016
Chris:

  I think that the most conservative solution is #2:

2. Check for references and don't unload if there are any.

The system should then complain in the Log "Cannot unload module <Name> because its procedures are still in use" or something to that effect. The programmer, who is developing the code, will be able to figure out that s/he installed these procedures somewhere.

Here is another thought: BlackBox has the FINALIZE section of the module. Perhaps it is the place where the checks could be performed? If the use of the exported procedures could be traced back in the FINALIZE section, then the finalizer can raise a trap. Trap in the finalizer would abort unloading the module. 

I am not sure how it relates to Andreas' work. Any comments?

W.
________________________________________
From: Oberon [oberon-bounces at lists.inf.ethz.ch <https://lists.inf.ethz.ch/mailman/listinfo/oberon>] on behalf of chris [chris at gcjd.org <https://lists.inf.ethz.ch/mailman/listinfo/oberon>]
Sent: Thursday, October 6, 2016 2:31 PM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Oberon for a C++ user.

On Thu, 6 Oct 2016 16:15:46 +0000, Skulski, Wojciech wrote:
> 1. Find all the references to the old (still loaded) code.
> 2. Get rid of the references.

That's the problem. How do you get rid of the references in procedure
variables?

Normal garbage collection does not deallocate the memory until all
references to the memory block have vanished by the usual progress of
the program. Until that has happened the old code is still available
unless you do anything to eliminate the references.

> Now you are ready to load the fresh code. At any given time there is
> only one copy of the code loaded to RAM. Since all is being done by
> the GC, and the machine is a single threaded machine with no
> preemption, it is not possible to interrupt the process.

That's not what I meant. The garbage collector in it's standard way
does not remove any references; it just checks them and deallocates
only heap blocks that don't have any references anymore.

If there are still references and you reload a modified module again
you have two incarnations of the module in the system.

In the end I see these possibilities.

1. Don't care, just unload like it currently is.

2. Check for references and don't unload if there are any.

3. Unload only removes the module from the module list. Check for
references and unload the code later from the garbage collector when no
references exist anymore.

4. Check for references and set them to NIL then unload.

5. Even more complicated ideas: like reload and unload in one step to
replace the references to the same procedures in the new module, a kind
of dynamic relinking.
I don't really suggest this, because this causes new problems if the
new module does not have the same procedures as the old one and binding
is done by name things get really messy.

I hope I have explained it better now. And obviously the problem is not
so easy to solve not because of it's implementation but because it's
not obvious how it should work correct.

Greetings, chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20161007/40b472ce/attachment.html>


More information about the Oberon mailing list