LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-11-2007, 12:51 AM   #1
rajesh_b
Member
 
Registered: Sep 2004
Location: Hyderabad.
Posts: 83

Rep: Reputation: 15
Stream buffer size of open file in GNU c library


Hi,

I have a doubt regarding buffer size provided by file stream. I know that what ever read or write we are doing on a open file ( FILE pointer of fopen()) will act on the buffer provided by GNU c library. I want to know the exact size of the buffer provided by GNU c library. Is there any way to configure this buffer size ?

Thanks in advance.


Regards,
Rajesh
 
Old 01-11-2007, 02:06 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,317

Rep: Reputation: 350Reputation: 350Reputation: 350Reputation: 350
Hi

Not really sure what the size is. But you can call setvbuf right after fopen so you can set it yourself. See "man setvbuf".

Edit:
Just looked at stdio.h and it has there is a:
#define BUFSIZ _IO_BUFSIZ

grep "#define _IO_BUFSIZ" /usr/include/*
/usr/include/libio.h:#define _IO_BUFSIZ _G_BUFSIZ

grep "#define _G_BUFSIZ" /usr/include/*
/usr/include/_G_config.h:#define _G_BUFSIZ 8192

So it's 8k. So increasing it with setvbuf is probably a good idea to save kernel calls to speed up things, if you're working with big files.

Last edited by Guttorm; 01-11-2007 at 12:06 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
buffer cache size gsr_kashyap Red Hat 6 09-18-2006 01:15 AM
Data buffer size MarcReing Programming 7 10-21-2004 12:51 PM
Caldera open Linux file size pve Linux - Distributions 2 07-23-2004 12:38 PM
CD write buffer size rch Linux - General 1 09-26-2003 05:50 PM
output file size Linux GNU gcc vs. DJGPP wsimmons Programming 5 01-27-2002 10:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration