Sponsored Content
Top Forums UNIX for Advanced & Expert Users Discussion on buffering of standard I/O library Post 302497716 by Edward114 on Thursday 17th of February 2011 09:14:46 PM
Old 02-17-2011
Java Discussion on buffering of standard I/O library

Hi,
There are three type of buffering: Fully buffered,line buffered,and unbuffered. The goal of the buffering provided by the standard I/O library is to use the minimum number of read and write calls.

I understand that decrease write() calls when use output function output data to a file , just like fputc().
Fully buffered: when the standard I/O buffer is filled,call write().
Line buffered: when a newline character encountered,call write().
Unbuffered: directly call write().

However, In input function case,just like use fgetc() input data from a file,we can use setvbuf() change buffer mode. then,how work the fgetc()? whether the buffer effect to decrease read() calls? especially line buffered? In my opinion, read() is not the ability to read a line.Smilie
 

We Also Found This Discussion For You

1. Solaris

Standard Template Library in Solaris 8.0

Hi Everybody, Can anyone guide me how to install SGI's STL Library on Solaris 8.0 ? Out of SGI's STL and STLPort, which third party STL is suitable, stable and thread-safe for UNIX Platform ? Please guide me over the above issue . Thanks & Regards Dinesh-Ahuja (0 Replies)
Discussion started by: md7ahuja
0 Replies
LIBSTDBUF(3)						   BSD Library Functions Manual 					      LIBSTDBUF(3)

NAME
libstdbuf -- preloaded library to change standard streams initial buffering DESCRIPTION
The libstdbuf library is meant to be preloaded with the LD_PRELOAD environment variable to as to change the initial buffering of standard input, standard output and standard error streams. Although you may load and configure this library manually, an utility, stdbuf(1), can be used to run a command with the appropriate environ- ment variables. ENVIRONMENT
Each stream can be configured independently through the following environment variables (values are defined below): _STDBUF_I Initial buffering definition for the standard input stream _STDBUF_O Initial buffering definition for the standard output stream _STDBUF_E Initial buffering definition for the standard error stream Each variable may take one of the following values: "0" unbuffered "L" line buffered "B" fully buffered with the default buffer size size fully buffered with a buffer of size bytes (suffixes 'k', 'M' and 'G' are accepted) EXAMPLE
In the following example, the stdout stream of the awk(1) command will be fully buffered by default because it does not refer to a terminal. libstdbuf is used to force it to be line-buffered so vmstat(8)'s output will not stall until the full buffer fills. # vmstat 1 | LD_PRELOAD=/usr/lib/libstdbuf.so STDBUF_1=L awk '$2 > 1 || $3 > 1' | cat -n See also the manpage of stdbuf(1) for a simpler way to do this. HISTORY
The libstdbuf library first appeared in FreeBSD 8.4. AUTHORS
The original idea of the libstdbuf command comes from Padraig Brady who implemented it in the GNU coreutils. Jeremie Le Hen implemented it on FreeBSD. BSD
April 28, 2012 BSD
All times are GMT -4. The time now is 08:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy