02-12-2013
While there are locks like mutex, I like to use threads in a flow paradign like shell scripts, with pipes or ring buffers from one to the next. On thread can be a dispatcher, writing buffers to many threads, and another might be a collector, reading buffers from many threads. Pipes let your threads block, which is nice as threads should not consume CPU when idle, but who wants to sleep and poll (sleep short and waste CPU, sleep long and add latency)? You can poll() or select() if you have many pipes to block on. Dispatcher and collector could be the same thread, so it can add or remove threads for demand.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
I was working on a shell script with randomly shows a page of text from a randomly selected topic .As soon as the page is displayed it callers a timer script which keeps on running indefinitely until the timer script is killed by the user.
This is where I have the problem,if I press... (2 Replies)
Discussion started by: mervin2006
2 Replies
2. Shell Programming and Scripting
I have never coded in perl before (just started today morning :). I need to write a perl program to automate a task.
Here is how I do it manually:
Start a program in my home dir. Now if I want to execute another program while this one is still running, what I would do is go to another... (6 Replies)
Discussion started by: the_learner
6 Replies
3. UNIX for Advanced & Expert Users
I am getting an Error Message as
=============================
starting Sortcl Merging And Aggregation
time: command terminated abnormally.
=============================
, when running a sortcl command.sortcl is a command for sorting large data,using cosort application installed in... (0 Replies)
Discussion started by: tkbharani
0 Replies
4. UNIX for Advanced & Expert Users
hi all,
i had created 3 threads using pthreads. Each thread does a different job. Now the main problem is when one thread generates a signal (for example SIGFPE, SIGINT) then the process terminates and all other threads do terminate eventually.
I want to keep other threads running i.e, i... (0 Replies)
Discussion started by: skyrulz
0 Replies
5. Shell Programming and Scripting
Hi,
I was using mpack to send mails using cronjob with attachments. It was working perfect. But recently it's behaving strangely. Its sending the mails without any error message but the mail is not getting delivered.
The code I was using:
/usr/local/bin/mpack -s "$SUBJECT" -d $MSGBODY... (0 Replies)
Discussion started by: itesh.dash
0 Replies
6. Shell Programming and Scripting
Hi Unix gurus,
I am facing a threading problem in Perl.
I have a worker thread in perl in which I am calling a shell script.
The shell script echo's output to the Standard Output from time to time as it progresses.
In the worker thread, I am unable to display the echo statement of shell... (1 Reply)
Discussion started by: som.nitk
1 Replies
7. Shell Programming and Scripting
Hi all , i know i ask a lot of question but these are really hard to solve and important question. I send two scripts:
expect.sh:
#!/usr/local/bin/expect
spawn ssh root@172.30.64.163
expect "login:"
send "root\n"
expect "password:"
send "root\n^M"
interact
and
son.sh:
... (2 Replies)
Discussion started by: fozay
2 Replies
8. Shell Programming and Scripting
Im having a problem launching multiple sub routines as threads. My script seems to stop when the first thread is launched.
Im condensing the code for simplification here:
#!/usr/bin/perl -w
use strict;
use threads;
srand;
my ($cnt,$line,$iprange_rand);
my... (2 Replies)
Discussion started by: trey85stang
2 Replies
9. HP-UX
HP-UX B.11.23 U 9000/800 636114222 unlimited-user license
I see this error in my logs sometimes and have very little info on it...
I have searched online for some documentation and haven't been able to find much on this issue.
The only thing I found on one site is that if my /tmp folder... (4 Replies)
Discussion started by: zixzix01
4 Replies
10. Shell Programming and Scripting
Hi everyone,
I am trying to create a script which runs a number of processes simultaneously and at the same time use a timer to keep track of what is going on.
The problem is that the timer stops and the script exits upon the completion of some of the processes, whereas I want to timer to... (0 Replies)
Discussion started by: free2rhyme2k
0 Replies
LEARN ABOUT REDHAT
pthread_kill_other_threads_np
PTHREAD_KILL_OTHER_THREADS_NP(3) Library Functions Manual PTHREAD_KILL_OTHER_THREADS_NP(3)
NAME
pthread_kill_other_threads_np - terminate all threads in program except calling thread
SYNOPSIS
#include <pthread.h>
void pthread_kill_other_threads_np(void);
DESCRIPTION
pthread_kill_other_threads_np is a non-portable LinuxThreads extension. It causes all threads in the program to terminate immediately,
except the calling thread which proceeds normally. It is intended to be called just before a thread calls one of the exec functions, e.g.
execve(2).
Termination of the other threads is not performed through pthread_cancel(3) and completely bypasses the cancellation mechanism. Hence, the
current settings for cancellation state and cancellation type are ignored, and the cleanup handlers are not executed in the terminated
threads.
AUTHOR
Xavier Leroy <Xavier.Leroy@inria.fr>
SEE ALSO
execve(2), pthread_setcancelstate(3), pthread_setcanceltype(3), pthread_cancel(3).
BUGS
According to POSIX 1003.1c, a successful exec* in one of the threads should terminate automatically all other threads in the program. This
behavior is not yet implemented in LinuxThreads. Calling pthread_kill_other_threads_np before exec* achieves much of the same behavior,
except that if exec* ultimately fails, then all other threads are already killed.
LinuxThreads PTHREAD_KILL_OTHER_THREADS_NP(3)