12-14-2009
MultiThreading using Pthreads
Situation:
i have multiple pthread_create calls like this:
pthread_create(...., ThreadFunc1,.....);
pthread_create(...., ThreadFunc2,.....);
.
.
which i am using to create multiple threads.All the "ThreadFunc<i>" functions are actually calling same function "Receive" of a class using same object of that class like this:
ThreadFunc1()
obj.Receive(<socket 1>); //receive data from socket 1
ThreadFunc2()
obj.Receive(<socket 2>); //receive data from socket 2
Question:
1.Will all the threads have their own copies of function "Receive", in order to provide concurrent receiving from all the receive sockets in application.
2. How is this approach different from:
while(1)
obj.Receive(<from all sockets one by one>);
where the same function polls all the receive sockets one by one to see for any data on them.
9 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Can anyone explain me how to use pthread_key_create() , pthread_setspecific(), pthread_getspecific() and pthread_key_delete () routines in pthreads.
Kindly state by an example. (3 Replies)
Discussion started by: S.P.Prasad
3 Replies
2. Programming
Does any one no of some good web site which will explain about how to program using pthreads in a UNIX enviroment? (6 Replies)
Discussion started by: fishman2001
6 Replies
3. Programming
howcome that pthtreads spawn 2 extra processes?
I'm kind of new with pthreads but fork() did not act like this.
Anyone who can give me a technical explanation of what happends with mother / daughter processes?
Best regards Esaia. (2 Replies)
Discussion started by: Esaia
2 Replies
4. Programming
I have created a thread program, it is attached. My problem is that I need to loop this program multiple times, and basically reset everything including the threads created previously. I try to loop the program, the first run is fine, as always, but the second run of the program, the initialize... (0 Replies)
Discussion started by: justgotthis
0 Replies
5. HP-UX
Hi!
I'm linking my hpux code using -lpthread (gcc), yet it references libpthread_tr.1,
the debug version of the pthread lib. How do I force it to use pthreads?
Thanks, :) (3 Replies)
Discussion started by: zackz
3 Replies
6. Programming
Hi all, I have a query about multithreading. What I would like to do is, at the start of my main update() function, start a couple of threads in parallel, once they are all complete carry on with my main update function.
void update() {
thread1->update(); // fluid solver
... (3 Replies)
Discussion started by: memoid
3 Replies
7. UNIX for Advanced & Expert Users
Hi,
Can you please give me a suitable reference to learn multithreading programming in C in UNIX?
Thanks (3 Replies)
Discussion started by: naan
3 Replies
8. Shell Programming and Scripting
Hi
I need to insert 1million records into MySQL database, but it is taking lot of time as there is no bulk insert support.
I want to spawn 10 processes which will insert 100k records each parallely.
Can somebody help me with a example program to execute this task through shell scripting. (5 Replies)
Discussion started by: sach_roger
5 Replies
9. Programming
I take this question of the The Linux Programming Interface: A Linux and Unix System Programming page 652 exercise 30.1
I want someone to explain the under line statement because it sounds complex to me couldn't understand anything
30-1 Modify the program (thread_incr.c) so that each loop in... (3 Replies)
Discussion started by: fwrlfo
3 Replies
LEARN ABOUT REDHAT
xml::grove::perlsax
XML::Grove::PerlSAX(3) User Contributed Perl Documentation XML::Grove::PerlSAX(3)
NAME
XML::Grove::PerlSAX - an PerlSAX event interface for XML objects
SYNOPSIS
use XML::Grove::PerlSAX;
$parser = XML::Grove::PerlSAX->new( [OPTIONS] );
$result = $parser->parse( [OPTIONS] );
# or
$result = $xml_object->parse( [OPTIONS] );
DESCRIPTION
"XML::Grove::PerlSAX" is a PerlSAX parser that generates PerlSAX events from XML::Grove objects. This man page summarizes the specific
options, handlers, and properties supported by "XML::Grove::PerlSAX"; please refer to the PerlSAX standard in `"PerlSAX.pod"' for general
usage information.
METHODS
new Creates a new parser object. Default options for parsing, described below, are passed as key-value pairs or as a single hash. Options
may be changed directly in the parser object unless stated otherwise. Options passed to `"parse()"' override the default options in
the parser object for the duration of the parse.
parse
Parses a document. Options, described below, are passed as key-value pairs or as a single hash. Options passed to `"parse()"' over-
ride default options in the parser object.
OPTIONS
The following options are supported by "XML::Grove::PerlSAX":
Handler default handler to receive events
DocumentHandler handler to receive document events
Source hash containing the input source for parsing
If no handlers are provided then all events will be silently ignored.
If a single grove argument is passed to the `"parse()"' method, it is treated as if a `"Source"' option was given with a `"Grove"' parame-
ter.
The `"Source"' hash may contain the following parameters:
Grove The grove object used to generate parse events..
HANDLERS
The following events are generated by "XML::Grove::PerlSAX". XML::Grove::PerlSAX passes the corresponding grove object as it's parameter
so the properties passed to the handler are those that were used to create or were assigned to the grove. Please see the docs for the
parser used to create the grove for a list of properties that were provided.
DocumentHandler methods
start_document
Receive notification of the beginning of a document. This is called from the XML::Grove::Document object before processing any docu-
ment content.
end_document
Receive notification of the end of a document. This is called from the XML::Grove::Document object after processing all document con-
tent.
start_element
Receive notification of the beginning of an element. This is called from the XML::Grove::Element object before processing any element
content.
end_element
Receive notification of the end of an element. This is called from the XML::Grove::Element object after processing all element con-
tent.
characters
Receive notification of character data. This is called from the XML::Grove::Characters object.
processing_instruction
Receive notification of a processing instruction. This is called from the XML::Grove::PI object.
comment
Receive notification of a comment. This is called from the XML::Grove::Comment object.
AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us
SEE ALSO
perl(1), XML::Grove(3)
Extensible Markup Language (XML) <http://www.w3c.org/XML>
perl v5.8.0 1999-08-17 XML::Grove::PerlSAX(3)