Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top