comp.lang.ada
 help / color / mirror / Atom feed
From: kaz@accton.shaw.ca (Kaz Kylheku)
Subject: Re: True faiths ( was Re: The true faith )
Date: Mon, 11 Feb 2002 20:13:31 GMT
Date: 2002-02-11T20:13:31+00:00	[thread overview]
Message-ID: <LBV98.13798$A44.710949@news2.calgary.shaw.ca> (raw)
In-Reply-To: a47r79$jf$1@news.panix.com

In article <a47r79$jf$1@news.panix.com>, David Combs wrote:
>In article <ZUm48.2916$Lv.376063@news.xtra.co.nz>,
>AG <nospam@nowhere.co.nz> wrote:
>>> Bruce Hoult wrote:
>>>
>>> > Garbage collection has a *lot* to do with this problem!
>>> >
>>> > A large proportion of assignments in languages such as C++ are done
>>> > merely in order to resolve the question of who owns an object and who is
>>> > responsible for eventually deleting it.
>>> >
>>> > With GC available, objects are seldom copied with pointers to them being
>>> > passed around instead.  You don't care who "owns" the object, because it
>>> > just magically goes away when all the pointers to it get forgotten.
>>
>>This doesn't seem to be a question of something "going away", it's a
>>question
>>of how the object(s) behave while they are still in use. For example:
>>
>>Suppose you have a process A which has something (an object or whatever)
>>called X it wants to pass to a process B. The process B must be free to do
>>whatever it wants to/with that X thing. However, the process A also wants to
>>keep going with the X after the B is done with whatever it was doing 
>
>Coroutines (across processes) help here?  You do have to
>know (not just when?) but *where*, in the source, you want
>to "resume" the other one.  Not at all "automatic".

Not really, because A and B want to use the object in parallel. Coroutines
make the synchronization problem go away, because coroutine A is suspended
when coroutine B is running and vice versa. The passing of control
is explicit.  With processes you don't have this, except maybe with
non-preemptive (cooperative) threads.

The solutions are to copy the object upfront, or to do some lazy copying:
copy on write. This is what happens with the memory pages of a process
on a moderm Unix system when you do fork(). Otherwise if B destructively
manpulates an object that A is also using, you have an instant race
condition.

Of course, there is the possibility of making a thread-aware object which
can be shared in some disciplined way. 

>NOW we DO have a problem: that call back into the
>first program, the one with memory-mngt via gc,
>just might eat up enough pieces of newly allocated
>memory that it triggers a gc!
>
>Thus pulling the rug out from under the 2nd program --
>since its reference back into the first program's
>data structure will be pointing to garbage, if
>the "shared" data structure gets slid somewhere
>else by the gc.

Firstly, you may be confusing GC with compacting-GC. It's not a
necessity for garbage collection to actually move data around to
eliminate fragmentation. The primary job of garbage collection is to
hunt down unreachable memory and liberate it.  If the GC in question is
non-compacting, you have nothing to worry about, (so long as the non-GC
domain isn't the only one with remaining references to the object, so
that it looks unreferenced in the GC domain).

If objects *can* be moved by the collector, what you can do is implement
the ability to lock some objects to prevent them from moving. Any objects
that are passed into the non-GC domain are locked, and then their
previous lock status is restored upon returning.

Making copies of objects into the non-GC domain, which have to be
liberated there, is also not out of the question. In the reverse
direction, any object created in the non-GC domain that you want to brring
into the GC domain will almost certainly have to be reallocated into
GC storage. The non-GC domain can be equipped with a special function
for allocating GC storage for objects in preparation for passing them
the GC domain, so the copy operation doesn't have to take place.

Since the non-GC domain is probably written in some stone age language
with manual memory allocation, its programmers won't mind learning some
special way of allocating memory. :)

>QUESTION: what kind of solutions are there to
>this problem?
>
>(The one I've been using is to turn off the
>gc during the first call out, and re-activating
>it when that first call returns -- the hope
>being that the 2nd call back in doesn't run
>out of memory!  (Actually, we make it do
>a preemptive gc before we freeze everything.)

This is equivalent to locking down everything, which is simpler, but
unnecessary.



  parent reply	other threads:[~2002-02-11 20:13 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <B85AB00A.3603%verec@mac.com>
     [not found] ` <%njZ7.279$iR.150960@news3.calgary.shaw.ca>
     [not found]   ` <B85BD264.370E%verec@mac.com>
     [not found]     ` <n7ybsg9lq8y.fsf@panix1.panix.com>
     [not found]       ` <3c36fbc5_10@news.newsgroups.com>
     [not found]         ` <gat-0501022256350001@192.168.1.50>
     [not found]           ` <4idg3u40ermnp682n6igc5gudp7hajkea9@4ax.com>
     [not found]             ` <gat-1001021155210001@eglaptop.jpl.nasa.gov>
     [not found]               ` <bruce-6C0AC5.10391411012002@news.paradise.net.nz>
     [not found]                 ` <gat-1001021515510001@192.168.1.50>
     [not found]                   ` <76be8851.0201101909.9db0718@posting.google.com>
     [not found]                     ` <gat-1101020950400001@eglaptop.jpl.nasa.gov>
2002-01-11 23:46                       ` True faiths ( was Re: The true faith ) israel r t
2002-01-12  0:38                         ` Steven T Abell
2002-01-13 12:20                           ` Kevin McFarlane
2002-01-13 18:52                             ` Erik Naggum
2002-01-14  8:12                               ` Espen Vestre
2002-01-14 10:40                                 ` israel r t
2002-01-16  6:42                                   ` Patrick Doyle
2002-01-16  8:00                                     ` israel r t
2002-01-16  8:55                                       ` Espen Vestre
2002-01-20  0:55                                         ` Mad Hamish
2002-01-20  1:18                                           ` Bruce Hoult
2002-02-13 16:31                                             ` Tom Hawker
2002-02-13 17:51                                               ` Larry Kilgallen
2002-02-13 23:28                                               ` Peter Gummer
2002-02-14  3:10                                                 ` Greg C
2002-02-14  1:56                                               ` Hartmann Schaffer
2002-02-14  9:59                                               ` Barry Watson
2002-01-16  8:00                                     ` " Do computers because it pays well" ( was Re: True faiths ) israel r t
2002-01-14 11:00                               ` True faiths ( was Re: The true faith ) Immanuel Litzroth
2002-01-18 15:19                                 ` Bob Bane
2002-01-18 17:44                                   ` René
2002-01-18 18:04                                   ` Hyman Rosen
2002-01-18 23:22                                     ` Richard Riehle
2002-01-18 23:53                                       ` Matthew Heaney
2002-01-20  5:39                                       ` Hyman Rosen
2002-01-20  5:59                                         ` Kaz Kylheku
2002-01-20 15:15                                           ` Software Scavenger
2002-01-21  1:42                                         ` Richard Riehle
2002-01-21  9:52                                           ` Hyman Rosen
2002-01-21 16:38                                             ` Richard Riehle
2002-01-21 20:30                                             ` Kaz Kylheku
2002-01-22  5:35                                             ` Raffael Cavallaro
2002-01-18 18:44                                   ` Simon Willcocks
2002-01-22 17:01                                     ` Hyman Rosen
2002-01-22 21:59                                       ` Bruce Hoult
2002-01-22 22:08                                         ` Hyman Rosen
2002-01-22 23:22                                           ` Kenny Tilton
2002-01-23 21:12                                             ` Hyman Rosen
2002-01-23 22:24                                               ` Tim Bradshaw
2002-01-24  0:15                                               ` Kenny Tilton
2002-01-24  8:14                                                 ` Hyman Rosen
2002-01-24 16:50                                                   ` Canconical C++ assignment (was Re: True faiths ...) Ray Blaak
2002-01-23  2:26                                           ` True faiths ( was Re: The true faith ) Bruce Hoult
2002-01-23 17:49                                             ` Richard Riehle
2002-01-22 22:09                                         ` Jim Rogers
2002-01-22 22:54                                           ` Kaz Kylheku
2002-01-22 23:47                                             ` Jim Rogers
2002-01-23  0:08                                               ` Ada SDL Eric Merritt
2002-01-23  1:39                                                 ` Rajat Datta
2002-01-23 10:52                                                 ` Preben Randhol
2002-01-23 13:59                                                   ` Eric Merritt
2002-01-23 16:48                                                     ` Preben Randhol
2002-01-23 16:01                                           ` True faiths ( was Re: The true faith ) Greg C
2002-01-26  0:40                                           ` AG
2002-02-11  7:18                                             ` David Combs
2002-02-11 17:50                                               ` Ray Blaak
2002-02-11 20:13                                               ` Kaz Kylheku [this message]
2002-02-13 21:17                                               ` Tom Hawker
2002-01-23 17:45                                         ` Georg Bauhaus
2002-01-18 19:36                                   ` Bruce Hoult
2002-01-18 19:57                                     ` Kaz Kylheku
2002-01-18 19:58                                     ` Marc Spitzer
2002-01-18 20:11                                       ` Ed Falis
2002-01-18 22:14                                         ` Kenny Tilton
2002-01-19  2:46                                           ` Thomas F. Burdick
2002-01-19  7:32                                     ` av1474
2002-02-13 23:12                                 ` Tom Hawker
2002-01-14 11:42                               ` Kevin McFarlane
2002-01-12  2:31                         ` Victor B. Putz
2002-01-12  3:56                         ` Kenny Tilton
2002-01-12  5:49                           ` israel r t
2002-01-12  6:04                             ` Thaddeus L Olczyk
2002-01-12  8:42                               ` Friedrich Dominicus
2002-01-12 15:44                             ` Andreas Bogk
2002-01-14 13:52                             ` Georg Bauhaus
2002-01-12 19:39                           ` Doug Hockin
2002-01-12 19:49                             ` Thaddeus L Olczyk
2002-01-12 20:14                             ` Kenny Tilton
2002-01-12 22:45                               ` Fernando Rodr�guez
2002-01-13  1:03                               ` Thomas F. Burdick
2002-01-13  5:24                                 ` Kenny Tilton
2002-01-12 15:58                         ` Preben Randhol
2002-01-12 16:18                           ` Nils Goesche
2002-01-12 17:03                             ` Thomas F. Burdick
2002-01-12 17:56                               ` Christopher Browne
2002-01-13  0:52                                 ` Thomas F. Burdick
2002-01-13 18:17                                   ` Nils Goesche
2002-01-13 19:04                                     ` Thomas F. Burdick
2002-01-13 19:26                                       ` James A. Robertson
2002-01-13 20:40                                         ` Nils Goesche
2002-01-13 20:43                                     ` Andreas Bogk
2002-01-13 19:05                             ` Preben Randhol
2002-01-13 19:20                               ` Preben Randhol
2002-01-16 12:00                           ` Christian Lynbech
     [not found]                       ` <9jtu3u8cq92b05j47uat3412tok6hq <3C409A34.7DE61ACB@nyc.rr.com>
2002-01-13 15:23                         ` Patrick Doyle
2002-01-13 16:29                           ` Dr. Edmund Weitz
     [not found]                       ` <9jtu3u8cq92b05j47uat3412tok6hq <i1t28.632$XG4.38637@news2.calgary.shaw.ca>
2002-01-22 14:25                         ` Copying semantics molehill (was Re: True faiths) Patrick Doyle
2002-01-22 15:47                           ` Steven T Abell
2002-01-26 17:32                             ` Patrick Doyle
2002-01-22 18:00                           ` Kaz Kylheku
2002-01-26 17:37                             ` Patrick Doyle
2002-01-28  3:08                           ` Robert Dewar
2002-01-28 18:47                             ` Patrick Doyle
2002-01-23  1:43                       ` True faiths ( was Re: The true faith ) Larry Kilgallen
     [not found]                       ` <9jtu3u8cq92b05j47uOrganization: LJK Software <FfppBdBcNxcL@eisner.encompasserve.org>
2002-01-23  2:04                         ` Jim Rogers
2002-01-23 17:02                           ` Darren New
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox