From: nagle@netcom.com (John Nagle)
Subject: Re: Thread-safe libraries for C++?
Date: Wed, 17 Feb 1993 18:15:53 GMT [thread overview]
Message-ID: <1993Feb17.181553.499@netcom.com> (raw)
In-Reply-To: rmartin.729901760@thor
rmartin@thor.Rational.COM (Bob Martin) writes:
>doel@bbq.uucp (Mike Doel) writes:
>|In order to use threads, you must use
>|"thread safe" libraries. Apparently, the standard C libraries aren't thread
>|safe. To counteract this, "jacket" routines have been developed which make
>|the standard Unix libraries thread safe (what does that mean?).
Much of the problem comes from a lack of any C++ language support
for concurrency. All locking must be coded with executable statements,
not implied in declarations. C++ has nothing like Modula or Ada monitors.
It would be desirable to be able to associate a mutex with either
a class or a class instance, as appropriate, so that the lock would be
set upon entry to the class via a public class member function
and released on return from that function. This would be the OOP
equivalent of a monitor. (Private functions don't need locking under
this model, since they are called from within the class.)
If a class has no static variables, then locking should, by default,
be at the instance level, so that multiple instances of the class can
be used simultaneously. If a class does have static variables, then
by default they should be protected by a class-level lock.
Sometimes you want different locking semantics, when you are
explicitly coding interprocess communication (as when implementing a
queue), and it should thus be possible to override the default.
A problem with class reentrancy remains, where a class member
calls out of the class and eventually, back in via a public member
function. This will deadlock. Of course, if the class isn't designed
for this sort of thing, it will probably do the wrong thing anyway.
A typical situation is when a function called by an iterator modifies
the list being iterated over. Existing systems screw up; with this kind
of locking, they would deadlock.
Ideally, you'd like to have a smart linker which could delete all
unnecessary locks after tracing the call graph, as well as detecting
the obvious deadlocks, but that's in the future.
Is anyone designing something like this?
John Nagle
John Nagle
next prev parent reply other threads:[~1993-02-17 18:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-02-12 18:43 Thread-safe libraries for C++? Mike Doel
1993-02-12 12:22 ` Jon C. R. Bennett
1993-02-13 18:17 ` Pete Becker
1993-02-14 22:26 ` Andrew Walduck
1993-02-12 20:40 ` Michael J. Grier
1993-02-16 17:54 ` Jim Robinson
1993-02-16 23:14 ` Michael J. Grier
1993-02-18 2:51 ` Michael Joosten
1993-02-18 22:05 ` Greg Brail
1993-02-16 22:29 ` Bob Martin
1993-02-17 18:15 ` John Nagle [this message]
1993-02-18 14:37 ` Andrew Condon
1993-02-22 20:22 ` Greg Brail
1993-02-16 22:30 ` Greg Brail
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox