Sponsored Content
Top Forums Programming MultiThreading using Pthreads Post 302380143 by Sastra on Monday 14th of December 2009 11:03:29 AM
Old 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

PThreads

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

pthreads

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

pthreads

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

PThreads

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

pthreads

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

multithreading on OSX

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

multithreading in UNIX

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

Multithreading program

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

Help with multithreading

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
Mail::Transport::Receive(3pm)				User Contributed Perl Documentation			     Mail::Transport::Receive(3pm)

NAME
Mail::Transport::Receive - receive messages INHERITANCE
Mail::Transport::Receive is a Mail::Transport is a Mail::Reporter Mail::Transport::Receive is extended by Mail::Transport::IMAP4 Mail::Transport::POP3 SYNOPSIS
my $receiver = Mail::Transport::POP3->new(...); my $message = $receiver->receive($id); DESCRIPTION
Each object which extends Mail::Transport::Receive implement a protocol which can get messages into your application. The internals of each implementation can differ quite a lot, so have a look at each separate manual page as well. Current message receivers: o Mail::Transport::POP3 Implements the POP3 protocol. See also Mail::Box::POP3. METHODS
Constructors Mail::Transport::Receive->new(OPTIONS) See "METHODS" in Mail::Transport Receiving mail $obj->receive([UNIQUE-MESSAGE-ID]) Receive one message from the remote server. Some receivers will provide the next message automatically, other are random access and use the specified ID. Server connection $obj->findBinary(NAME [, DIRECTORIES]) See "Server connection" in Mail::Transport $obj->remoteHost() See "Server connection" in Mail::Transport $obj->retry() See "Server connection" in Mail::Transport Error handling $obj->AUTOLOAD() See "Error handling" in Mail::Reporter $obj->addReport(OBJECT) See "Error handling" in Mail::Reporter $obj->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) Mail::Transport::Receive->defaultTrace([LEVEL]|[LOGLEVEL, TRACELEVEL]|[LEVEL, CALLBACK]) See "Error handling" in Mail::Reporter $obj->errors() See "Error handling" in Mail::Reporter $obj->log([LEVEL [,STRINGS]]) Mail::Transport::Receive->log([LEVEL [,STRINGS]]) See "Error handling" in Mail::Reporter $obj->logPriority(LEVEL) Mail::Transport::Receive->logPriority(LEVEL) See "Error handling" in Mail::Reporter $obj->logSettings() See "Error handling" in Mail::Reporter $obj->notImplemented() See "Error handling" in Mail::Reporter $obj->report([LEVEL]) See "Error handling" in Mail::Reporter $obj->reportAll([LEVEL]) See "Error handling" in Mail::Reporter $obj->trace([LEVEL]) See "Error handling" in Mail::Reporter $obj->warnings() See "Error handling" in Mail::Reporter Cleanup $obj->DESTROY() See "Cleanup" in Mail::Reporter $obj->inGlobalDestruction() See "Cleanup" in Mail::Reporter DIAGNOSTICS
Warning: Avoid program abuse: specify an absolute path for $exec. Specifying explicit locations for executables of email transfer agents should only be done with absolute file names, to avoid various pontential security problems. Warning: Executable $exec does not exist. The explicitly indicated mail transfer agent does not exists. The normal settings are used to find the correct location. Error: Package $package does not implement $method. Fatal error: the specific package (or one of its superclasses) does not implement this method where it should. This message means that some other related classes do implement this method however the class at hand does not. Probably you should investigate this and probably inform the author of the package. SEE ALSO
This module is part of Mail-Box distribution version 2.105, built on May 07, 2012. Website: http://perl.overmeer.net/mailbox/ LICENSE
Copyrights 2001-2012 by [Mark Overmeer]. For other contributors see ChangeLog. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.14.2 2012-05-07 Mail::Transport::Receive(3pm)
All times are GMT -4. The time now is 11:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy