diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-29 14:21:31 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-03-29 14:21:31 +0000 |
commit | e16d9f54360f6c7c3a410c14e0eb881877371ea5 (patch) | |
tree | 3e172a5d42f21351ebcf1f5b21bc388ebd665de0 /nuttx/lib/lib_vfprintf.c | |
parent | c34b8df9eb4095e6a22260e6677751db319fe33c (diff) | |
download | px4-nuttx-e16d9f54360f6c7c3a410c14e0eb881877371ea5.tar.gz px4-nuttx-e16d9f54360f6c7c3a410c14e0eb881877371ea5.tar.bz2 px4-nuttx-e16d9f54360f6c7c3a410c14e0eb881877371ea5.zip |
Moved exclusion logic to a higher level so that printf output is more readable when the same stdout FILE* is shared
by many pthreads (tasks did not have this probablem because they have separate stdout streams).
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@174 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib/lib_vfprintf.c')
-rw-r--r-- | nuttx/lib/lib_vfprintf.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nuttx/lib/lib_vfprintf.c b/nuttx/lib/lib_vfprintf.c index 7d1b666a4..fe8b1a744 100644 --- a/nuttx/lib/lib_vfprintf.c +++ b/nuttx/lib/lib_vfprintf.c @@ -87,7 +87,15 @@ int vfprintf(FILE *stream, const char *fmt, va_list ap) */ lib_stdstream(&stdstream, stream); + + /* Hold the stream semaphore throughout the lib_vsprintf + * call so that this thread can get its entire message out + * before being pre-empted by the next thread. + */ + + lib_take_semaphore(stream); n = lib_vsprintf(&stdstream.public, fmt, ap); + lib_give_semaphore(stream); } return n; } |