Re: printk and \n

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

On Sat, Sep 25, 2010 at 5:08 PM, Philip Downer wrote:
> javad karabi wrote:
>>
>> I am very curious about this.
>> Where exactly does the "hello" text go, before it is 'flushed' ?
>> I am thinking that it gets put in some other buffer, then 'flushing' the
>> buffer does something
>> to the effect of memcpy the buffer to the framebuffer?
>
> stdout is buffered, the '\n' newline character means that fflush is called
> on stdout and so the buffer is flushed. You can turn the buffer off using
> "setbuf(stdout, NULL);" and the output will immediately be displayed.

Actually, there are 3 buffering modes supported in userspace.

1 - unbuffered. Every character is flushed out immediately
2 - line buffered. Characters are not flushed until a newline is encountered
3 - fully buffererd. Characters are not flushed until the buffer is filled.

In cases 2 or 3, if you perform an input operation, then any
unbuffered characters will be flushed.

Here's some documentation:
<http://linux.die.net/man/3/setvbuf>

-- 
Dave Hylands
Shuswap, BC, Canada
http://www.DaveHylands.com/

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux