문제

On Linux application level all printf messages go to stdout and all err messages goto stderr. Where

stderr is usually unbuffered and

stdout is line-buffered

So at kernel space when we use printk() with or without KERN_ERR and such other level specifying macro then how this messages are buffered?

Does dmesg has any separate mechanism?

도움이 되었습니까?

해결책

All that printk() does is to simply add few more bytes into in-memory ring-buffer (and wrap around if end of buffer reached). So, it does not make sense to say whether it is line-buffered or not - this just does not apply.

Also, while in user space stdout, stderr make sense, this is not the case in kernel and for printk(): it does not write to stdout because there is no such thing in kernel.

Granted, something takes care of actually delivering contents of this ring-buffer to the user - whether it is printing it on serial console or retrieving it with dmesg, and this typically looks for LF characters to separate lines.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top