Question about execution of threads and parent/child processes
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Question about execution of threads and parent/child processes




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Question about execution of threads and parent/child processes  
Andrew Falanga


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:26 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register