This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: newlib stdio and thread cancellation
- From: Steven Abner <pheonix at zoomtown dot com>
- To: newlib at sourceware dot org
- Date: Fri, 25 May 2012 19:31:30 -0400
- Subject: Re: newlib stdio and thread cancellation
- Authentication-results: smtp01.cincibell.synacor.com header.from=pheonix@zoomtown.com; sender-id=unknown
- Authentication-results: smtp01.cincibell.synacor.com smtp.mail=pheonix@zoomtown.com; spf=unknown; sender-id=unknown
- Authentication-results: smtp01.cincibell.synacor.com smtp.user=pheonix@zoomtown.com; auth=pass (LOGIN)
- References: <20120523130837.GA3827@calimero.vinschen.de>
- X_cmae_category: 0,0 Undefined,Undefined
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".