Hong Zhang wrote:

> That was not what I meant. Your code already assume the existence of
> reference counting. It does not work well with any other kind of garbage
> collection. If you translate the same code into C without putting in
> the close(), the code will not work at all.

Wrong, it does *not* assume any such thing.  It assumes that when a
filehandle goes out of scope it is closed.  How that is achieved is a
detail of the implementation, and could be done in a number of ways.  It
could just as well be done by keeping the filehandle on a stack which
was cleared when the scope exits.  C++ does this for local variables
without requiring a refcount.  

> By the way, in order to use perl in real native thread systems, we have
> to use atomic operation for increment/decrement reference count. On most
> systems I have measured (pc and sparc), any atomic operation takes about
> 0.1-0.3 micro second, and it will be even worse on large SMP machines.
> The latest garbage collection algorithms (parallel and cocurrent) can
> handle large memory pretty well. The cost will be less DF.

I think you'll find that both GC *and* reference counting scheme will
require the heay use of mutexes in a MT program.

Alan Burlison

Reply via email to