01-23-04 10:08 PM
Hello everybody,
I have a question about how things are executed (I do realize it's up
to the scheduler in the OS, in this case Linux, Red Hat 9) in
multi-threaded apps and such.
I have an application where I'm dumping > 16mb of data on to a file
descriptor and the network interface card (using the socket()
connect() and send() calls), that is 16mb on both, total of > 32mb.
I have written two different versions of the program because I was
concerned that my first attempt at writing multi-threaded apps wasn't
doing what I thought it was. In the first, the multi-threaded
version, main() opens a thread that writes the data on to the network,
and main() dumps the data to /dev/lp0.
In the other version, I use fork() to create a child that does the
network stuff while the parent does the /dev/lp0 stuff. I've written
some basic status stuff in to the program, by basic I mean that at
intervals some status strings are printed to stdout in the form of
fprintf(stdout, "child/thread still kicking").
The deal is though, I don't think that the execution is happening in
paralle in either case. For instance, when either is run, all the
child/thread1 stuff is printed to stdout first, then the
parent/thread0 stuff after that. I would have expected that the
programs would be executing in a parallel manner. Parent/thread0 for
a while, child/thread1 for a while, parent/thread0 for a while, ...
etc.
Any suggestions?
Andy
[ Post a follow-up to this message ]
|