This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Thread-safe libio [was Re: BUG in libstdc++ ... libio ... pthreads]


Ulrich Drepper wrote:
> 
> Andreas Gruenbacher <a.gruenbacher@infosys.tuwien.ac.at> writes:
> 
> >  a) use flockfile() / funlockfile() to lock the file for each I/O
> > operation.
> >     Advantage: simple
> >     Disadvantage: high overhead
> 
> It is no question that this is the method to be used.

In code like this:

  istream is; ostream os; char c;
  while (is >> c) os << c;

it causes four system calls per character :-((  I believe it _is_ a
question whether this overhead is acceptable or not.

> Putting the
> codlocking code directly in the code is simply unacceptable.  Simply
> using a mutex or so without access to the thread library calls for
> priority inversion problems.

What do you mean by that? f[un]lockfile() does mutual exclusion too,
with similar problems as mutexes (priority inversion, deadlock as in
the example I mailed to the list yesterday, etc.)


Andreas

-----------------------------------------------------------------------
 Andreas Gruenbacher, Vienna University of Technology, Student
 a.gruenbacher@infosys.tuwien.ac.at
 Contact information: http://www.infosys.tuwien.ac.at/~agruenba

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]