Hi,

I will briefly answer now and return with more later.

On torsdag, feb 20, 2003, at 17:30 Europe/Stockholm, Jim Bodwin wrote:


Note that this worked just fine with the old 5.005 threads (which shared everything). I understand that they have ripped the old 5.005 threads out starting with 5.10 but you can still use 5.005 threads with current versions of Perl. We (GreenLight) have been using 5.005 threads in production code for years and it works great (although we did NOT use locks - we count on scheduling).

Are you using 5.005 threads in 5.005 or in 5.6/5.8, since all new features added in 5.6/5.8 did not take threading in consideration, they are not threadsafe.

I understand GreenLight is having trouble with the fact that 5.005 threads are leaving, but if you were ever running more than one thread at the same time, I fail to see how you could have failed to segfault in the extreme amount of cases perl was not threadsafe.

What do you mean "count on scheduling"?

5.005 threads were a true threading system that was well integrated into Perl and allowed full use of Perl data structures. Eduardo's example shows one of the key advantages: with 5.005 threads you can use any variable normally without restriction. That includes deferencing and updating. All threads work from the same copy. The Perl garbage collector automatically released space when the reference count went to zero. The power of this is somewhat subtle yet easy to use and truly remarkable (I know of no other language that can do this). The ithread copy/share scheme is not nearly as powerful and makes some things virtually impossible (as Eduardo has discovered). Here is a snippet of sample code - if someone can tell me how to do this with ithreads I'll be greatful:

sub newThreadForFoo {
my foo $ref = shift;
Thread->new(sub {wait(3); if ($ref->{Ready} {update($ref)});
}

same code should work, if whatever $ref is point at is shared.

Don't try this with C/C++ - the value of $ref will be popped off the stack by the time the thread starts. With ithreads $ref cannot be dereferenced and (even if it could) the update routine is given a COPY of $ref and everything that it points to so updating it is useless. Perl with 5.005 threads is the only language I know of that handles this correctly.

Not if the target is

I'm not trying to say that ithreads are not a Good and Useful thing - they are just a totally different programming paradigm than 5.005 threads. But ithreads is nowhere near a replacement for 5.005 threads (at least with the current implementation).

So what is lacking in the current implementation?

At GreenLight are trying to decide what to do in the future - retrofit the old 5.005 code back into 5.10 and beyond or make significant modifications to ithreads so that the 5.005 paradigm can be supported (it isn't clear if the latter is possible).


I would be happy to discuss how ithreads can be extended the need of 5.005 users, I think retrofitting the old 5.005 code is possible, but if you want to use the new features, it would require a lot of work. Way more work than it took to get ithreads working.

Arthur

Reply via email to