LinuxQuestions.org
Help answer threads with 0 replies.
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 09-03-2007, 01:58 PM   #1
Strahlemann
LQ Newbie
 
Registered: Sep 2007
Location: Switzerland
Distribution: Scientific Linux 4.5
Posts: 1

Rep: Reputation: 0
Strange high system CPU usage in a multithreaded program


Dear Linuxers

I'm encountering a strange problem with a multithreaded program I just wrote. It does a lot of mmap'ed I/O on large (~100-500M) files, with mostly randomly distributed access all over the whole file: in a nutshell, it fetches some randomly distributed bytes, does a rather long computation (~ 1000 - 1500 machine instructions), and writes the results back (to the mapped pages).

Now the program doesn't scale well when starting it as a multithreaded program: it spends a lot of time in system CPU mode (40-60%), even though there is no single system call in the running threads (besides indirect I/O via mapped pages). I assigned several parts of the input file to the threads, thus there are no mutexes involved, just a POSIX semaphore in the controlling thread which waits for the completion of other threads. (I tried with pthread_join instead, but the effect is exactly the same).

The funny thing is: if I start it on the command line as several separate processes doing exactly the same, there is almost no system CPU usage, all of CPU time is available for user computation, and it does the computation much faster.

Did any of you encounter a similar problem, and how did you eventually solve it?

Best regards, Stefan

Machine: Dual Opteron 270, running in 64-bit mode
Memory: 8GB (thus, no swapping necessary)

Last edited by Strahlemann; 09-03-2007 at 02:01 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
High CPU usage ?! Why? skate Linux - Software 1 04-11-2007 06:55 AM
High Cpu usage untak Debian 21 01-23-2007 07:21 AM
why high load, but no cpu usage? JustinHoMi Linux - General 6 01-11-2006 11:43 AM
cpu usage high corbintechboy VectorLinux 2 07-27-2005 09:11 AM
Why do I have a High System CPU Usage Bottleneck linuxboy69 Linux - Software 3 09-02-2004 04:55 PM

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

All times are GMT -5. The time now is 11:11 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