LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 09-14-2005, 07:37 PM   #1
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Rep: Reputation: 15
Slow multithreading with 2.6.13


I've been having a strange problem with my computer. Here's a java example.

Code:
  1 public class Threads {
  2         public static void main(String[] args) {
  3                 int myInt = 0;
  4                 while (true) {
  5                         try {
  6                                 Thread.sleep(1);
  7                                 myInt++;
  8                                 System.out.println(myInt);
  9                         } catch (InterruptedException e) {
 10                                 System.out.println("ERROR");
 11                         }
 12                 }
 13         }
 14 }
This should sleep for 1 milisecond and then continue, but in actuality it sleeps a lot longer than that. It does sleep and then continue, but it doesn't do it correctly. This program will spit out about 70 numbers in 10 seconds on my computer when there are plenty of free resources. The strange thing is that when there *aren't* free resources, it goes a lot faster. By running 'yes 1' in one terminal and then running that java program in another it will put out about 1300 numbers in 10 seconds.

I think this might have something to do with the kernel, but I'm not sure. When I tryed running a different kernel (2.6.11-hardended (selinux)) it ran faster but still improved when i used up resources.

I'm pretty sure it's not a java problem becuase I't s clean install and it does it in some other programs as well (written in C I believe)

Here's some information about my computer
It's a Dell M70 notebook
Pentium-M 2.0 Ghz.
Linux kernel 2.6.13, with libata-dev patch (it's a sata drive) and software suspend2 patch. but like i said, it also did simmilar stuff on a 2.6.11 hardened without patches.
I'm running gentoo 2005.1 with all the recent updates. It's "~x86" so that might be causing some of it.

spenceal-2# lspci
0000:00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 03)
0000:00:01.0 PCI bridge: Intel Corporation Mobile 915GM/PM Express PCI Express Root Port (rev 03)
0000:00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 03)
0000:00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 03)
0000:00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 03)
0000:00:1d.2 USB Excerpts From The First Annual Nerd BowlController: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 03)
0000:00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 03)
0000:00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 03)
0000:00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d3)
0000:00:1e.2 Multimedia audio controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller (rev 03)
0000:00:1e.3 Modem: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Modem Controller (rev 03)
0000:00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 03)
0000:00:1f.2 IDE interface: Intel Corporation 82801FBM (ICH6M) SATA Controller (rev 03)
0000:00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 03)
0000:01:00.0 VGA compatible controller: nVidia Corporation NV41 [Quadro FX Go1400] (rev a2)
0000:02:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express (rev 01)
0000:03:01.0 CardBus bridge: Texas Instruments PCI6515 Cardbus Controller
0000:03:01.5 Communication controller: Texas Instruments PCI6515 SmartCard Controller
0000:03:03.0 Network controller: Broadcom Corporation BCM4309 802.11a/b/g (rev 03)

Let me know if any other information would be helpfull.
 
Old 09-14-2005, 08:00 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

It's probably your Pentium-M throttling down when there's not much to do. When you run 'yes 1' you give the processor something to do, the the clock speed is raised, giving the whole system more throughput.

Dave
 
Old 09-14-2005, 08:33 PM   #3
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Original Poster
Rep: Reputation: 15
ok, is there any way around this? aka, tell the processor that it needs to be working harder?
 
Old 09-14-2005, 08:40 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Have a look here:
http://www.gentoo.org/doc/en/power-m....xml#doc_chap3
It should be possible to switch scaling off altogether.

Dave
 
Old 09-14-2005, 08:49 PM   #5
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Original Poster
Rep: Reputation: 15
Thank you, that is has got to be some of the fastest reply I've ever seen. I'll look into that link, but i dont have drivers or something installed yet, and I would like to learn more about power management anyway, so again, thanks.
 
Old 09-15-2005, 10:59 PM   #6
mipsv
LQ Newbie
 
Registered: Jan 2005
Location: Boston, MA
Distribution: GNU, Redhat
Posts: 7

Rep: Reputation: 0
Maybe Im missing something but Im not sure what version of jdk/jre you are using:

So, It looks like you are hitting the infamous timer resolution boundary! Try a value for sleep that is not a multiple of 10... try a value of 9 first. Really small numbers seem to be a bit unpredictable. Im general it might be better for you to reorder code if you absolutely need a 1ms delay.

This only mentions windows but it should give some idea.

http://bugs.sun.com/bugdatabase/view...bug_id=5091934
 
Old 09-15-2005, 11:30 PM   #7
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Original Poster
Rep: Reputation: 15
no, it was totally unrelated to java, I recompiled my kernel, (i had been working on getting it trimed down some anyway) and it seemed to fix something, I'm not sure of the exact feature that was causing the problems, but it works now. It might have been something to do with power management as I did mess with those a bit.
 
Old 09-16-2005, 12:50 PM   #8
MrMichaelWill
LQ Newbie
 
Registered: Nov 2003
Posts: 10

Rep: Reputation: 0
Quote:
Originally posted by andy753421
no, it was totally unrelated to java, I recompiled my kernel, (i had been working on getting it trimed down some anyway) and it seemed to fix something, I'm not sure of the exact feature that was causing the problems, but it works now. It might have been something to do with power management as I did mess with those a bit.
Where did you get the kernel you used before recompiling it?

Did it come preinstalled? What linux distribution was that?

Michael
 
Old 09-16-2005, 04:29 PM   #9
andy753421
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 65

Original Poster
Rep: Reputation: 15
It was a self compiled kernel (gentoo), it seemed to have that problem on several different kernels actually. I know it had that problem on knoppix 3.8.1 (as well as the keyboard not working, but that's unrelated).
 
  


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
PHP Multithreading dlublink Linux - Software 1 10-25-2005 12:23 PM
Multithreading jayashrik Programming 1 07-20-2005 04:13 AM
java: multithreading ashirazi Programming 5 06-23-2005 09:50 AM
Strange multithreading live_dont_exist Programming 2 05-01-2005 07:26 PM
multithreading libraries Pres Programming 3 06-20-2003 03:27 AM

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

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