This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: newlib stdio and thread cancellation


On May 23, 2012, at 9:08 AM, Corinna Vinschen wrote:

> Consider a scenario where multiple threads call printf.  The vfprintf
> function is secured against concurrent usage of the same descriptor
> by calling _flockfile/_funlockfile.

Corinna, I have a question. I am not sure why concurrent or serialization
of parsing is needed. Wouldn't that defeat the purpose of threading? I can
see actual syscall write locking a descriptor, but what if 3 threads use
vfprintf on one descriptor, does it matter which thread writes first, or in the
case of one being canceled, that only 2 write in a certain sequence?
I ask in earnest, because I viewed from a different position.
I saw vfprintf as a userland function which should perform its
operation of parsing and once done, to send off for writing.
  If viewed as I have done, then you have a third option with which you
can add to solutions. But the new solution would be a slight re-write of
the vfprintf function such that only the write() function creates the lock/unlock
on the descriptor. This might not be a solution for embedded due to a
small increase in memory usage due to a double buffer type concept, not
writing each parse instantaneously.

Steve
"The only dumb question is the one you don't ask".


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