Sponsored Content
Top Forums Programming How to use pipe() in multiple threads? Post 25755 by Marc Rochkind on Monday 5th of August 2002 12:47:41 AM
Old 08-05-2002
There should be no difference at all between piping between two threads or two processes.

The important thing about pipes, no matter how they're connected, is to use each as a one-way-conduit, despite its ability to be two-way. That way you avoid synchronization problems. In your question, it sounds like the direction of data flow is one directional, which means that one pipe should do the trick.

What is it about threads that is making you think there is anything unusual going on? Can you maybe phrase your question more specifically?
Marc Rochkind
 

10 More Discussions You Might Find Interesting

1. Programming

synchronizing multiple threads in unix

hi all! I wanted to know how to synchronize multiple threads in unix It would be better if someone give some code samples Thanx (1 Reply)
Discussion started by: bankpro
1 Replies

2. IP Networking

How to choose Multiple process or Multiple threads?

Hi All, Please explain me when i have to use multiple process and when I have to use Multiple threads? Please give me an example.It will be very helpful for me. Thanks in advance. (0 Replies)
Discussion started by: ashleykumar
0 Replies

3. UNIX for Dummies Questions & Answers

Threads with pipe and select?

Hi. I just found this site while searching for some info on a problem and thought I'd see if anyone else knows the answer. I have two threads that are connected by a pipe. Thread A can write to the pipe and Thread B can read the data from the pipe. My problem is that when I use select() in... (3 Replies)
Discussion started by: willil
3 Replies

4. Shell Programming and Scripting

Spawning multiple threads in Unix

Hi, I need to spawn mutilpe threads , each invoking a different set of shell scripts, in parallel. What would be the best way to do that. Any sample script would greatly help. I am a novice at Unix so any help is much appreciated. Thanks (5 Replies)
Discussion started by: neeto
5 Replies

5. UNIX for Advanced & Expert Users

Which IPC between multiple threads will suit most in scenerio?

Hi Friends, I am designing a solution for a problem: in which my master thread receiving network message and processing them, during processing of each message i need to communicate remote database (that is actually a separate external module)that cause a delay of arount 2 second (), After... (1 Reply)
Discussion started by: johnray31
1 Replies

6. Programming

File access from multiple processes or threads?

Hi, Can anyone give me any idea when multiple processes access a file (like opening it, modifying it etc.) how can the synchronization can be done if they can access the same file at any time? How can this scenario is different from when multiple threads access a same file, modifying it etc- in... (7 Replies)
Discussion started by: sanzee
7 Replies

7. UNIX for Dummies Questions & Answers

Copy files in Multiple Threads

Hello all, I have a directory of files of varying sizes. I want to copy all these files in n number of threads to another directory such that each copy set is more or less the same size. Example : Say /mydirA It has around say 23 files of various sizes. Number of copy... (0 Replies)
Discussion started by: samoo
0 Replies

8. Shell Programming and Scripting

How to make this run in multiple threads

Hi, I have a list of URLs in a csv file which I'm checking for page status. It just prints the URL and the status as output. This works perfectly fine. I'm looking to run this in multiple threads to make this process faster. I'm pretty new to Perl and I managed to complete this. It would be... (9 Replies)
Discussion started by: kzenthil
9 Replies

9. Shell Programming and Scripting

How to start multiple threads in Solaris?

Hello, In a unix Solaris environment, (for simulation) how to start multiple threads (as Light Weight Process, not background process)? thanks, J. (7 Replies)
Discussion started by: seafan
7 Replies

10. Shell Programming and Scripting

Need to create multiple threads

Hi , i need to run multiple scripts parallely ,on my server....i have 8 cpus . planning to run minimum of 6 scripts paralley ....could you please suggest someone . thanks in advance , (3 Replies)
Discussion started by: Huvan
3 Replies
thr_join(3C)						   Standard C Library Functions 					      thr_join(3C)

NAME
thr_join - wait for thread termination SYNOPSIS
cc -mt [ flag... ] file...[ library... ] #include <thread.h> int thr_join(thread_t thread, thread_t *departed, void **status); DESCRIPTION
The thr_join() function suspends processing of the calling thread until the target thread completes. The thread argument must be a member of the current process and cannot be a detached thread. See thr_create(3C). If two or more threads wait for the same thread to complete, all will suspend processing until the thread has terminated, and then one thread will return successfully and the others will return with an error of ESRCH. The thr_join() function will not block processing of the calling thread if the target thread has already terminated. If a thr_join() call returns successfully with a non-null status argument, the value passed to thr_exit(3C) by the terminating thread will be placed in the location referenced by status. If the target thread ID is 0, thr_join() finds and returns the status of a terminated undetached thread in the process. If no such thread exists, it suspends processing of the calling thread until a thread for which no other thread is waiting enters that state, at which time it returns successfully, or until all other threads in the process are either daemon threads or threads waiting in thr_join(), in which case it returns EDEADLK. See NOTES. If departed is not NULL, it points to a location that is set to the ID of the terminated thread if thr_join() returns successfully. RETURN VALUES
If successful, thr_join() returns 0. Otherwise, an error number is returned to indicate the error. ERRORS
EDEADLK A joining deadlock would occur, such as when a thread attempts to wait for itself, or the calling thread is waiting for any thread to exit and only daemon threads or waiting threads exist in the process. ESRCH No undetached thread could be found corresponding to the given thread ID. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ SEE ALSO
thr_create(3C), thr_exit(3C), wait(3C), attributes(5), standards(5) NOTES
Using thr_join(3C) in the following syntax, while (thr_join(0, NULL, NULL) == 0); will wait for the termination of all non-daemon threads, excluding threads that are themselves waiting in thr_join(). SunOS 5.10 27 Mar 2000 thr_join(3C)
All times are GMT -4. The time now is 05:33 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy