11-20-2008
Thank you for your response Murphy!
Quote:
Originally Posted by
fpmurphy
You have two problems (1) the pthreads model and API is defined for the C language but not for C++
I have rewritten the code in C, but it doesn't seem to help.
Quote:
(2) you are creating your threads as DETACHED. Therefore they are not JOINABLE and thus main() does not and cannot wait for your threads to terminate.
My primary intention is not to have the parent wait for other threads, but to execute the detachable threads. As I did not find any other alternative mechanism to execute the detachable threads, I introduced sleep statement; it worked . However, I would like to replace the sleep() with some function of Pthread lib or find a way to execute the detachable threads even if the parent terminates.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
is there a way to make my script wait before doing something without using the "sleep _" command? (4 Replies)
Discussion started by: Blip
4 Replies
2. UNIX for Advanced & Expert Users
Hi
I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running.
My Code:
... (1 Reply)
Discussion started by: albertashish
1 Replies
3. Shell Programming and Scripting
Hi All,
I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program.
I want 1st script to wait until the 'C' program completes.
I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies
4. Shell Programming and Scripting
Hi all,
I have a shell that kicks off several sub-shells and make them run parallelly, like:
shell1.sh &
shell2.sh &
shell2.sh &
...
However, since all sub-shells run parallely, the parent shell finished right after it's submitted, like:
$ parent.sh &
$ + Done parant.sh &
$
... (2 Replies)
Discussion started by: visio2000
2 Replies
5. Shell Programming and Scripting
I am trying to find a list of files and writing it to a text file. Based on the machine performance the file writing will be slow at certain time.
The code to find file and redirecting the output to text file is on a shell script
/usr/bin/find $SEARCH_DIR -daystart \( \( -name 'KI*' -a... (4 Replies)
Discussion started by: nuthalapati
4 Replies
6. Programming
Hello,
I have the following problem:
I have makefileproj and makefilemod in a build process for a complex project - from makefileproj I call the makefilemod.
In makefilemod I generate a list containing objects eg,: "../../../25_Build/Results/Objects/FBL/Fls.o... (4 Replies)
Discussion started by: marina_lmv
4 Replies
7. Programming
Parent Thread Of Child Thread
Suppose a process creates some threads say threadC and threadD.
Later on each of these threads create new child threads say threadC1, threadC2, threadC3 etc. So a tree of threads will get created.
Is there any way to find out the parent thread of one such... (1 Reply)
Discussion started by: rupeshkp728
1 Replies
8. Programming
Hello. I want to make a child do some stuff,wait,then the parent does some stuff and then child does some stuff and waits again.I have made the following but it does not work.Can anybody help me?
pid1 = fork();
if (pid1 == -1)
{
perror("Can't create child\n");
... (18 Replies)
Discussion started by: Cuervo
18 Replies
9. Shell Programming and Scripting
I have two scripts lets say A.expect and B.sh needs to be executed.
I am executing B.sh from A.expect where B.sh has sleep command.
My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits.
but my A.expect should execute only after completing B.sh.
Is... (3 Replies)
Discussion started by: priya@2012
3 Replies
10. Shell Programming and Scripting
Hi all,
I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens.
could anyone please tell me how to make parent to wait in child process in shell script?
thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies
thread(9s) thread(9s)
NAME
thread - General: Contains kernel threads-related information
SYNOPSIS
----------------------------
Member Name Data Type
----------------------------
wait_result kern_return_t
----------------------------
MEMBERS
Specifies the outcome of the wait. The kernel can set this member to one of the following values: THREAD_AWAKENED, THREAD_INTERRUPTED,
THREAD_TIMED_OUT, THREAD_SHOULD_TERMINATE, and THREAD_RESTART.
DESCRIPTION
The thread data structure contains kernel threads-related information. Kernel modules typically use the wait_result member (with the cur-
rent_thread routine) to check for the result of the wait. The values associated with the wait_result member have the following meanings:
The result of the assert wait is a normal wakeup. The wait condition was interrupted by the clear_wait routine. The specified timeout has
expired. The result of the assert wait is that the current kernel thread should terminate. The current kernel thread should be restarted.
NOTES
The header file <thread.h> shows a typedef statement that assigns the alternate name thread_t for a pointer to the thread data structure.
Many of the kernel threads-related routines operate on these pointers to thread data structures.
The thread data structure is an opaque data structure; that is, all of its associated members (except for the wait_result member) are ref-
erenced and manipulated by the operating system and not by the user of kernel threads.
FILES
SEE ALSO
Routines: clear_wait(9r), current_thread(9r), thread_block(9r), thread_set_timeout(9r), thread_wakeup(9r), thread_wakeup_one(9r)
thread(9s)