LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
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



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 10:59 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
Open Source Consulting | Domain Registration