On Tue, 04 Nov 2008 16:43:49 -0500, Eric Sosman
<Eric.Sosman@su n.comwrote:
I may address the rest of your comments later (for which, thank
you very much) but this seems to be a serious point of confusion
so let me expand. What we can have is the following sequence of
events:
At time A we create bobble X. Space will be allocated for X as
needed, including a struct bobble_s.
At time B we schedule operation zeta to be performed on X at time
E. Don't assume that X 'knows' that about the scheduled
operation.
At time C we delete bobble X. All space is deallocated.
At time D we allocate bobble Y. As it chances, Y has the same
address as X.
At time E the program attempts to peform the scheduled operation
on X. It has to be able to detect that X is no longer there even
though there is a bobble around with X's address.
Simply hashing the address into an integer won't work because the
addresses are the same. Likewise using an opaque pointer doesn't
work. That's the point of the "unique id" - it is different for
different bobbles even though they have the same address.
Of course you can use sequence numbers as keys in a hash table or
some kind of search tree, but that is relatively computationally
expensive compared to the descriptor/locator paired structs.
Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
<Eric.Sosman@su n.comwrote:
>Richard Harter wrote:
>
As far as I can see, the curve is orthogonal to the rest of
>the discussion, so I'll ignore it. Your issues appear to deal with
>representati on hiding and validity checking, not with garbage
>collection.
>Suppose we are writing a program in C and that we have a
>particular kind of object (in the sense of OO programming) that I
>will call bobbles. Being well disciplined programmers (Ha!) we
>create a module to package our bobble related functions together.
>>
>If we were using an OO based language there would be machinery in
>place, constructors, destructors, and such like, to handle the
>details of our module, but in C we have to roll our own.
>>
>One of the things we need to do is to create functions that will
>serve as constructors and destructors. There are two things that
>we have to take care of, specifying the interface, and writing
>the function internals. My concern is with specifying the
>interface.
>>
>I am going to throw in one curve ball. Our program will contain
>references to created bobbles; we won't know where these are so
>they can go stale when we delete bobbles. The code will need to
>be able to detect that a reference has gone stale and deal with
>it appropriately.
>particular kind of object (in the sense of OO programming) that I
>will call bobbles. Being well disciplined programmers (Ha!) we
>create a module to package our bobble related functions together.
>>
>If we were using an OO based language there would be machinery in
>place, constructors, destructors, and such like, to handle the
>details of our module, but in C we have to roll our own.
>>
>One of the things we need to do is to create functions that will
>serve as constructors and destructors. There are two things that
>we have to take care of, specifying the interface, and writing
>the function internals. My concern is with specifying the
>interface.
>>
>I am going to throw in one curve ball. Our program will contain
>references to created bobbles; we won't know where these are so
>they can go stale when we delete bobbles. The code will need to
>be able to detect that a reference has gone stale and deal with
>it appropriately.
As far as I can see, the curve is orthogonal to the rest of
>the discussion, so I'll ignore it. Your issues appear to deal with
>representati on hiding and validity checking, not with garbage
>collection.
you very much) but this seems to be a serious point of confusion
so let me expand. What we can have is the following sequence of
events:
At time A we create bobble X. Space will be allocated for X as
needed, including a struct bobble_s.
At time B we schedule operation zeta to be performed on X at time
E. Don't assume that X 'knows' that about the scheduled
operation.
At time C we delete bobble X. All space is deallocated.
At time D we allocate bobble Y. As it chances, Y has the same
address as X.
At time E the program attempts to peform the scheduled operation
on X. It has to be able to detect that X is no longer there even
though there is a bobble around with X's address.
Simply hashing the address into an integer won't work because the
addresses are the same. Likewise using an opaque pointer doesn't
work. That's the point of the "unique id" - it is different for
different bobbles even though they have the same address.
Of course you can use sequence numbers as keys in a hash table or
some kind of search tree, but that is relatively computationally
expensive compared to the descriptor/locator paired structs.
Richard Harter, cri@tiac.net
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
Comment