basic books/guides on multithreading programming?
Andrae Muys
amuys at shortech.com.au
Sun Feb 17 23:09:43 EST 2002
Cliff Wells <logiplexsoftware at earthlink.net> wrote in message news:<mailman.1013816158.26552.python-list at python.org>...
> On Sat, 16 Feb 2002 05:57:09 +0700
> Tripp Scott wrote:
>
> > which ones do you recommend? examples in any language is fine,
> > though i prefer python, perl, or ruby. what i would like is
> > guidance on what is thread safety, how to achieve it, what are
> > the issues in multithreading programming, the global interpreter
> > lock, and other basics.
>
> It's been many years since I've read a book on multi-threading, so I can't
> suggest a good title, but it's a lot simpler than you might think (given
> the fact you're looking for a book ;) This is especially true with Python,
> which has a remarkably easy-to-use threading library (use the threading
> module, not the thread module).
>
> Thread-safety boils down to this: lock any /shared/ resource that might be
> /modified/ by a thread. End of story. You can get into all sorts of
> debates about when these locks are necessary, but 99% of the time they are,
> and the other 1% isn't worth the effort to decide whether they really are
> or not.
>
"End of Story" is a rather interesting way to summarise the issues of
Deadlock, Lock-ordering, Livelock, Starvation, Convoying, and
Lock-Contention to name a few of the problems you may face moving from
serial to parallel algorthims (although the last two only affect
perfomance, not correctness).
I don't have the time to discuss these further atm, and I am not
personally aware of a readily accessable text on concurrent
programming. Ben-Ari "Principles of Concurrent Programming" PH '82
was the text used when I studied this back in university, however it
is a little dry. OTOH, I am very reluctant to recommend any of the
language/library specific texts to someone without an existing
knowledge of concurrency issues. Even Kleiman, Shah, and Smaalders
"Programming with Threads" (an excelent book, covers libpthread based
programming in C/C++) gives rather preemptory coverage of the problems
involved.
Unfortunately without an understanding of the problems, it is hard to
understand/apply the solutions provided by the various
languages/libraries described.
Cliff: Sorry I can't answer your question straight away, maybe check
your local library (possibly uni-library) for a copy of Ben-Avi. If
you have any problems mapping the concepts he discusses to specific
Python code I (and I imagine the rest of c.l.py) will do what I can to
help. Other then that, WHY do you feel you need threads? Or is this
just a "Something new to learn" question?
Tripp: If I sound a bit harsh, I'm sorry. Understand that as someone
with their name attached to a unexpectedly widely distributed tutorial
on threading, I get *alot* of help requests from new programmers who
think that threading is "just another library to learn", and approach
it as such (with the inevitable trouble). Your "End-of-story"
statement was just more then I would reasonably let pass without
comment.
Everyone: Does anyone know of an accessable concurrency text? One
that moves from discussing the basics (data-races, critical sections,
mutural exclusion, lock-order based deadlock, resource based deadlock,
etc) to the various solutions (mutex/cond-var, semaphore, monitor,
rendezvous) to the various design approaches (master-slave, pipeline,
work-pile, etc). Possibly even a discussion of various performance
considerations (convoy's, wait-free synchronisation, cache-aliasing,
spin vs. blocking locks, etc).
Andrae Muys
More information about the Python-list
mailing list