Walt Mankowski on 6 Dec 2011 15:13:50 -0800


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [Philadelphia-pm] Reminder: tech meeting Monday night, December 5


On Tue, Dec 06, 2011 at 05:25:29PM -0500, John Kominetz wrote:
> I have to say I was a little confused from the start because of the
> statement that each thread was a complete interpreter. I "interpreted" that
> as each thread was actually a separate PROCESS, and that all this was
> hijacking threads as a metaphor for inter-process communication. So I wrote
> a test with five threads that each waited for 30 seconds and watched the
> activity monitor.  It reported one perl process with six threads, running
> for 30 seconds. End of Duh.

In ithreads, there's one process for everything, and each perl thread
is a complete perl interpreter running inside an operating system
thread.

But you're partially right. Even though they are threads, because
they're isolated from each other, Perl has to do some magic internally
in order to share data. Also perl lets you do things that pthreads
doesn't allow, suck as dynamically sharing and unsharing variables at
run time.

What you described is actually what forks.pm does. That module lets
you use the same api as threads, but it instead of creating threads it
forks new processes. All the data sharing is done using sockets.

If I ever give this talk again, I'll try to be clearer about all this.

> That also renders moot my question about "threads" surviving beyond the
> lifetime of the caller. Being real (OS) threads, that's not possible.
> Changing my test from join() to detach(), the threads die unexpected,
> untimely deaths as the process comes crashing down upon them.

In fact the guy down at the other end of the room (sorry, I didn't
catch your name) had exactly that problem. He called me over to say
that he was trying to run one of my examples but it wasn't
working. Turned out he was calling detach() instead of join().

Walt

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Philadelphia-pm mailing list
Philadelphia-pm@pm.org
http://mail.pm.org/mailman/listinfo/philadelphia-pm