[Techtalk] multithreaded C program
jcv at hise.org
Fri Nov 30 14:17:05 EST 2001
I am trying to port a stress test from C for Windows (that probably has an
official name - I have no idea what it is) to both Solaris and Linux.
Since I knew I had to do both (I did Solaris first), I tried to keep it
ANSI C/Posix threads, but I am running into a problem running the program
on Linux that I didn't have in Solaris. The basic structure of the program
is this: According to parameters provided by the user of X disks to be
exercised and Y threads per file,
|-> launches thread to maintain statistics and time test
|-> launches X threads (one per disk)
| |-> each of these threads launches Y threads which
| | continuously do reads +/or writes to their
| | assigned addresses in their specified drive
| |waits to join Y threads when time is up
| waits to join X threads when time is up
So, I have two problems with this code in Linux that I don't have in
1) I can't open more than one fstream at a time. In the Solaris man page
for fwrite, it says that you are limited by OPEN_MAX (max number of files
a process can have open), which is defined in limits.h as 256 (and
possibly further limited by a POSIX_OPEN_MAX of 16). In Linux, I can't
find a similar defintion. Does anyone know if there is a limit of 1 open
file per process or if I need to do something to get around what seems to
be this limitation?
2) My second problem probably derives from the first, but I will mention
it anyway in case anyone can help me solve it; it is with the Y threads.
They are each calculated to have non-overlapping sections of the drive
that they do their reads and writes on; but, when the program tries open a
second file pointer to the same file, I get a seg fault (as above with
file pointers to different files).
Some technical details:
gcc 2.96 on RH 7.0
gcc 2.95.2 on Caldera 3.1
gcc 2.95.3 on SuSE 7.2
WorkShop Copilers 5.0 98/12/15 C 5.0 on Solaris 8 (x86)
(works the way I want it to)
cc -mt -o fracture fracture.o lx_procs.o lx_io.o -lpthread
Thanks for any help or pointers you can give me!
More information about the Techtalk