From: pete@borland.com (Pete Becker)
Subject: Re: Thread-safe libraries for C++?
Date: Sat, 13 Feb 1993 18:17:57 GMT [thread overview]
Message-ID: <1993Feb13.181757.1904@borland.com> (raw)
In-Reply-To: gfT2ATS00WBEA4Tjhf@andrew.cmu.edu
In article <gfT2ATS00WBEA4Tjhf@andrew.cmu.edu> jb7m+@andrew.cmu.edu (Jon C. R. Bennett) writes:
>
>the stream class should not obtain the mutex for you since few aplications
>would need it, if thats what you want then, write a subclass of streams
>that does the locks and then just calls the normal stream methods
>
That doesn't really solve the problem:
cout << "This is " << "a test\n";
Even if the inserters handle serialization themselves, there's no
guarantee that you won't get a context switch between invocations of the
inerters. If two threads both called this code, the result could be
something like this:
This is This is a test
a test
There are really two separate issues that a programmer faces when
dealing with multiple threads: making sure that individual functions can be
used safely with threads, and making sure that the program logic is correct
when using threads. Serialization control inside the iostream library
addresses the first issue, but not the second. Without serialization control,
this erroneous program may well crash. With it, the program displays
nonsense. From a user's perspective, there's not a big difference between the
two results.
-- Pete
next prev parent reply other threads:[~1993-02-13 18:17 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 [this message]
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
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