openFile and threads

Peter Thiemann
Fri, 10 Jan 2003 18:26:11 +0100


one thing that I gleaned from Matthias's strace output is the fcntl
system calls to obtain the locks. They are not really needed for my application
and could be avoided using the POSIX library. 
However, this does not seem to be a big issue just from the cost of the
system calls, because there is no noticeable difference between
Matthias's C programs.
> But it sounds like in your case you need to open lots of (small?) files.
> What do you do with the contents of the files?

Yes, the files are small. They typically contain less than 10 words. 
These words are key words and the Select program selects file names based
on boolean expressions formed from the key words.

What I'm actually doing is implementing a data base for email messages, where
these file names are the primary keys for the messages. Each message is 
represented by two files of the same name (but in different directories),
the data file containing the raw message, and the meta data file that just
contains a list of key words.

Keeping the meta data in this way allows for smooth interaction with file
synchronization across several computers. So it's necessary that each set
of key words resides in its own file.
I have created a web page with a little more argumentation about it:
The downloadables may be a bit out of date, but you get the idea.

Hope that helps.