LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-23-2011, 07:33 AM   #1
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Rep: Reputation: 24
Angry process hangs up upon receiving more than 8 or 10 signals in centos-5


Hi all,

My program is creating 4 threads per transaction. Threads doing nothing but simply sleeping.

Now, when transaction ends, I want to wake up all the threads from sleeping. For this I am using pthread_kill() to wake up the threads using signal SIGUSR2.

Problem raises when I put more transactions(eg. 100 trans). My process gets hangup.

What to do ?
 
Old 07-24-2011, 03:00 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
4 threads/transaction * 100 transactions ?!? And 400+ pthread_kill(), presumably all at once?

Sounds like a really, really poor design strategy

SUGGESTIONS:
* How can you refactor your design such that you never need more than 10-12 threads at a time (instead of 400++ at a time)?

* How can you insure that the threads you have are actively doing useful work most of the time (instead of idlely consuming resources)?

* Why not consider "signaling" a waiting thread with something like a condition variable or a mutex, instead of a kill?
 
Old 07-25-2011, 01:43 AM   #3
vdx
Member
 
Registered: Aug 2007
Location: The Greate INDIA
Distribution: CentOS, RHEL, Fedora
Posts: 102

Original Poster
Rep: Reputation: 24
Wink

Quote:
4 threads/transaction * 100 transactions ?!? And 400+ pthread_kill(), presumably all at once?

Sounds like a really, really poor design strategy
This is a proxy machine which transfers ip calls from one end to other. Thus it requires these many of threads.

Quote:
* How can you refactor your design such that you never need more than 10-12 threads at a time (instead of 400++ at a time)?
I cant do that because I cant predict no of calls at a single point of time.

Quote:
* How can you insure that the threads you have are actively doing useful work most of the time (instead of idely consuming resources)?
I am doing some imp work in kernel space while thread is sleeping in user space. It wont consume any resource while sleeping.

Quote:
* Why not consider "signaling" a waiting thread with something like a condition variable or a mutex, instead of a kill?
I already tried that, but it requires condition checking, which is also a cpu consuming operation, so want to resolve this issue on signaling basis.

by the way thanx for the reply.
 
Old 07-25-2011, 08:31 AM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
A proxy server certainly does not require "hundreds of threads."

Let me draw a simple real-world analogy of how a fast food restaurant would work with your design:
  1. A customer walks into the store.
  2. The manager pulls out four boxes and adds a drop of water to the top of each.
  3. Pooooff!! "Just Add Water!" Four fully-trained employees appear!
  4. Three of the four employees immediately fall asleep. One takes your order.
  5. All four employees wake up and wade into the kitchen, which is brimming with employees trying to fill different orders with only one stove and one fryer.
  6. After an unpredictable (but very long) amount of time, the employees come out of the kitchen. They hand you the order, then all four of them promptly fall dead.

Now, consider how a grease-joint actually works, and consider how that might influence the design of your server.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rexec and sending signals to the remote process. oyhaare Programming 0 03-15-2011 08:06 AM
LINUX packet receiving process vahu002 Linux - Networking 0 12-08-2010 03:30 PM
signals in Linux process aayu09 Linux - Software 1 04-07-2010 12:45 AM
Relationship between ASCII control codes and Process Signals jhwilliams Linux - Software 2 06-12-2009 03:51 PM
Sending SIGKILL/signals to process and all children? thecake Linux - Newbie 1 12-22-2008 04:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:39 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration