LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-23-2009, 09:11 AM   #1
mhogue
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Rep: Reputation: 0
Alternative to threads


Hi all i have a program that comes up and spawns 10 threads that each contain a UDP socket. As you can imagine this eats up a lot of %CPU. I was curious is there something that I could use in place of the threads to lower the %CPU?
 
Old 12-23-2009, 10:03 AM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Quote:
As you can imagine this eats up a lot of %CPU
No I'm not...
10 Threads is really nothing, the problem is probably more related to what are the threads doing? If they're polling on a condition without sleeping between test, only 1 thread is sufficient to see your CPU burn...
 
1 members found this post helpful.
Old 12-23-2009, 12:36 PM   #3
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by mhogue View Post
As you can imagine this eats up a lot of %CPU.
Sounds like bad programming. Are you doing blocking reads on the sockets? Are you using a blocking select to determine when to read a socket? If not, the CPU usage is your fault.

I wrote a TCP server that spawned a separate thread for each connection from 120 separate clients that were constantly communicating. CPU usage was around 25%.
 
Old 12-24-2009, 06:41 AM   #4
mhogue
LQ Newbie
 
Registered: Aug 2009
Posts: 9

Original Poster
Rep: Reputation: 0
So I figured it out thanks for the replies though. I'm using UDP multicast not TCP by the way, I have several threads that are send and several that are receiving. I discovered when the transmission rate was extremely high e.g. 60 Hz and 1024 packet sizes it would spike my cpu usage. With a change to each packet size was able to knock it down a lot thanks for the help
 
Old 12-31-2009, 03:18 PM   #5
David1357
Senior Member
 
Registered: Aug 2007
Location: South Carolina, U.S.A.
Distribution: Ubuntu, Fedora Core, Red Hat, SUSE, Gentoo, DSL, coLinux, uClinux
Posts: 1,302
Blog Entries: 1

Rep: Reputation: 107Reputation: 107
Quote:
Originally Posted by mhogue View Post
I'm using UDP multicast not TCP by the way...
Can you describe your architecture in more detail? Why are you using multicast instead of unicast?

Quote:
Originally Posted by mhogue View Post
I have several threads that are send and several that are receiving.
Are all the threads running on the same machine? Is the machine sending multicast packets to itself? Do you have more than one machine? If so, how are the machines arranged?

Quote:
Originally Posted by mhogue View Post
I discovered when the transmission rate was extremely high e.g. 60 Hz and 1024 packet sizes it would spike my cpu usage.
Assuming 10 senders, 60 * 10 * 1024 * Hz = 600 KB/s = 7.2 Mbps. If your Ethernet is only 10 Mbps and running in half-duplex mode, I see a potential problem.

Once again, assuming 10 senders, 60 * 10 * Hz = 600 packets per second.

I would not consider either number very large assuming you are using a Pentium 4 class machine with gigabit Ethernet to do the processing. What processing to you perform on each packet?
 
  


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
some threads are become unnoticed because of large number of continious threads deepak_cucek LQ Suggestions & Feedback 9 08-20-2009 11:21 PM
Execution threads vs normal threads jonty_11 Linux - General 2 03-26-2008 10:37 AM
"Find all threads started by user" not showing all threads Nylex LQ Suggestions & Feedback 3 12-28-2005 08:28 PM
Java threads listed using kill -3 does not contain all threads found using ps -auxww coneheed Programming 2 11-14-2005 08:57 AM
Java Threads vs Native Threads rjmendez Programming 0 08-16-2004 05:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:45 AM.

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