You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/04/23 10:13:48 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on issue #3599: Syslog thread-safety

xiaoxiang781216 commented on issue #3599:
URL: https://github.com/apache/incubator-nuttx/issues/3599#issuecomment-825555585


   > Its root cause is that `nx_vsyslog()` does not execute atomically. It makes multiple unprotected calls to `lib_sprintf()`.
   > So, if two threads are logging simultaneously, their respective calls to `lib_sprintf()` will interfere with each other.
   > 
   
   This can be fixed by va_format extension from linux kernel:
   ```
   struct va_format
   
   	%pV
   
   For printing struct va_format structures. These contain a format string
   and va_list as follows:
   	struct va_format {
   		const char *fmt;
   		va_list *va;
   	};
   
   Implements a "recursive vsnprintf". And here is an implementation I made recently:
   https://github.com/j256/dmalloc/pull/89/commits/6f4d29da098e985ab284b837eb5e45009f1b45e8#diff-e7a46ef823b649b77cffce4a4a8d4cbe508b35c6ce4fc54ebc39a1d1895ad85cR378-R384
   https://github.com/j256/dmalloc/pull/89/commits/6f4d29da098e985ab284b837eb5e45009f1b45e8#diff-f2e6c18de8171e389aeff0b8d25b2755253108a59a13baf7167c2ffa0af36a58R529-R537
   
   > 
   > **Semaphore**
   
   semaphore isn't enough here, we need the critical section to sync with the interrupt handle. Since the critical section will block all hardware interrupt process, and the serial is very slow, the lock will make a significant impact on the runtime behaviour.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org