473,807 Members | 2,766 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

hyperthreading locks up sleeping threads

Below are 2 files. The first is a Python program that isolates the
problem within less than 1 hour (often just a few minutes). The second
is a C++ program that shows that the Win32 Sleep() function works as
expected (ran from Friday afternoon until Monday morning).

Note, the Python programs hangs (stops responding) with hyper-threading
turned on (a BIOS setting), but works as expected with hyper-threading
turned off.

This problem happens on Windows only (not on Linux for days).

Variations of the Python program also lock up:

Tried importing win32api instead of time and using the
win32api.GetTic kCount() and win32api.Sleep( ) methods.

Tried using lock = threading.Event () and lock.wait() instead of
time.sleep().

Tried import Queue using q = Queue.Queue() and q.get(True, self.t).

Note, the Windows task manager shows 2 CPUs on the Performance tab with
hyper-threading is turned on.

Both Python 2.3.5 and 2.4.3 (downloaded from python.org) have this
problem.

The operating system is MS Windows XP Professional.

winmsd.exe shows:
2CPUs: x86 Family 15 Model 4 Stepping 1 GenuineIntel ~3000 MHz
Version: 5.1.2600 Service Pack 2 Build 2600

Could someone with a hyper-threading (or dual core or multi processor)
CPU please
confirm this bug?

Many Thanks

Olaf
Here is the expected output of both programs (the progam has locked up
if the numbers stop printing):
python testsleep.py
thread 1 started, sleep time 0.010
thread 2 started, sleep time 0.003
1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1
# testsleep.py
import threading
import time

class Task(threading. Thread):
def __init__(self, n, t):
threading.Threa d.__init__(self )
self.n = n # thread id
self.t = t # sleep time
def run(self):
print 'thread %d started, sleep time %.3f' % (self.n, self.t)
count = 0
printCount = int(10 / self.t)
while True:
start = time.clock()
time.sleep(self .t)
stop = time.clock()
if stop - start > 1.0:
print 'thread', self.n, stop - start

count += 1
if count > printCount:
count = 0
print self.n, # print sign of live

def test():
thread1 = Task(1, 0.01) # thread 1, sleep 10 ms
thread2 = Task(2, 0.003) # thread 2, sleep 3 ms
thread1.start()
thread2.start()

test()

----------------------------------------------------------------------------------

// testsleep.cpp
// Compiled with Visual C++ version 6 as a Win32 console application.

#include <windows.h>
#include <stdio.h>
#include <time.h>

typedef struct {
int id;
int ms;
} param_s;
DWORD WINAPI threadFunction( LPVOID param)
{
param_s* p = (param_s*)param ;
long elapsedTime;
long time1, time2;
long printCount = long(10000 / p->ms); // loop iterations in 10
seconds
long count = 0;

printf("thread %d started, sleep time: %d ms" "\n", p->id, p->ms);

while(true) {
time1 = GetTickCount();
Sleep(p->ms);
time2 = GetTickCount();

elapsedTime = time2 - time1;
if(elapsedTime > 1000)
printf("thread %d slept for %d ms" "\n", p->id,
elapsedTime);

count++;
if(count > printCount) {
count = 0;
printf("%d ", p->id); // print sign of live
}
}

return 0;
}
int main(int argc, char* argv[])
{
long time1, time2;
param_s p1, p2;

p1.id = 1;
p1.ms = 10;

p2.id = 2;
p2.ms = 3;

time1 = GetTickCount();
while(true) {
time2 = GetTickCount();
if (time1 != time2) {
printf("clock resolution: %d ms" "\n", time2 - time1);
break;
}
}

CreateThread(NU LL, 0, threadFunction, (void*)&p1, 0, NULL);
CreateThread(NU LL, 0, threadFunction, (void*)&p2, 0, NULL);

getchar(); // wait until the user presses the enter key.

return 0;
}

May 8 '06 #1
14 2123
[Ol********@gmai l.com]
Below are 2 files. The first is a Python program that isolates the
problem within less than 1 hour (often just a few minutes).
It does not on my box. I ran that program, from a DOS shell, using
the released Windows Python 2.4.3. After an hour, it was still
printing. I left it running, and started a second instance of the
test program from another DOS box. That was 4 hours ago, and both
instances are still printing.
...
Note, the Python programs hangs (stops responding) with hyper-threading
turned on (a BIOS setting), but works as expected with hyper-threading
turned off.
Hyper-threading was turned on here.
...
Note, the Windows task manager shows 2 CPUs on the Performance tab with
hyper-threading is turned on.
Same here, although do note that whether the Performance tab shows one
or two CPUs when HT is enabled depends on how the user sets Task
Manager's View -> CPU History option.
Both Python 2.3.5 and 2.4.3 (downloaded from python.org) have this
problem.
I used the python.org 2.4.3.
The operating system is MS Windows XP Professional.
Same here.
winmsd.exe shows:
2CPUs: x86 Family 15 Model 4 Stepping 1 GenuineIntel ~3000 MHz
Version: 5.1.2600 Service Pack 2 Build 2600
Different processor here:

2CPUs: x86 Family 15 Model 3 Stepping 4 GenuineIntel ~3400 Mhz
Version 5.1.2600 Service Pack 2 Build 2600
Could someone with a hyper-threading (or dual core or multi processor)
CPU please confirm this bug?


Not me, and I'm tired of trying :-)
May 8 '06 #2
Tim

Many thanks for trying and reporting the details of your environment.
All our hyper-threading PC are identical. However, we identified one
that is different and we are installing Windows XP on it now ...

My hope is that other people will try this, too.

Olaf

May 8 '06 #3

Ol********@gmai l.com wrote:
Tried importing win32api instead of time and using the
win32api.GetTic kCount() and win32api.Sleep( ) methods.


What about win32api.SleepE x? What about

WaitForMultiple Objects
WaitForMultiple ObjectsEx
WaitForSingleOb ject
WaitForSingleOb jectEx

when the object is not expected to produce events and the function
timeouts?

May 8 '06 #4
Ol********@gmai l.com wrote:
Below are 2 files. The first is a Python program that isolates the
problem within less than 1 hour (often just a few minutes). The second
is a C++ program that shows that the Win32 Sleep() function works as
expected (ran from Friday afternoon until Monday morning).

Note, the Python programs hangs (stops responding) with hyper-threading
turned on (a BIOS setting), but works as expected with hyper-threading
turned off.

.......
I ran this on winxp ht+python-2.4.3 for about 16 hours and no lockup.
--
Robin Becker

May 10 '06 #5
Ol********@gmai l.com schreef:
Below are 2 files. The first is a Python program that isolates the
problem within less than 1 hour (often just a few minutes). The second
is a C++ program that shows that the Win32 Sleep() function works as
expected (ran from Friday afternoon until Monday morning).

Note, the Python programs hangs (stops responding) with hyper-threading
turned on (a BIOS setting), but works as expected with hyper-threading
turned off.

This problem happens on Windows only (not on Linux for days). The operating system is MS Windows XP Professional. Could someone with a hyper-threading (or dual core or multi processor)
CPU please
confirm this bug?


Doesn't lock up on my system after 6 hours. Windows XP Pro, Python
2.4.2, hyperthreading Pentium 4.

--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
May 10 '06 #6
Dave send me the below as an email. Olaf

Hi Olaf,

I'm running your test for you - it's been going for about an hour now
and is continuing to generate output[1].

c:\>py
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)]
on win32
Type "help", "copyright" , "credits" or "license" for more information.


winmsd says:
OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 1 Build 2600
Processor x86 Family 15 Model 2 Stepping 9 GenuineIntel ~2992 Mhz
Processor x86 Family 15 Model 2 Stepping 9 GenuineIntel ~2992 Mhz

(it's a hyperthreaded P4 - not 2 true CPUs - so it should be similar to
your setup)

-Dave

[1] Here's the output (line breaks added by my email program):

c:\Temp>testsle ep.py
thread 1 started, sleep time 0.010
thread 2 started, sleep time 0.003
1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2
1 2 1 2 1
1 2 1 2
1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1
2 1 2 1 1
2 1 2 1
2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1
1 2 1 2 1
2 1 2 1
2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1
2 1 2 1 2
1 2 1 1
2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1
2 1 2 1 2
1 1 2 1
2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2
1 2 1 1 2
1 2 1 2
1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2
1 1 2 1 2
1 2 1 2
1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2
1 2 1 2 1
2 1 2 1
1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2
1 2 1 2 1
2 1 1 2
1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1
2 1 2 1 1
2 1 2 1
2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1
2 1 1 2 1
2 1 2 1
2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1
2 1 2 1 2
1 2 1 2
1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1
2 1 2 1 2
1 2 1 1
2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 1 2
1 2

May 10 '06 #7
Robin and Roel

Thanks for trying and reporting the results. Both of you and Tim and
Dave have run the .py program now (all on hyper-threaded CPUs) and none
of you were able to reproduce the problem.

So that indicates that there is something special about our PC. We are
planing to re-install Windows XP (and nothing else) and try again.

Also, we have one other PC (with a different configuration/CPU) and are
planing to do the same to that PC.

Olaf

May 10 '06 #8
No lockup for me after 28 hours.

Of course, I don't have HT. It's a dual Opteron system with WinXP.

May 10 '06 #9
This is an update on what we found so far:

We located one other PC that was not identical to the PC with the
problem. So we installed Windows XP on it and ran the Python test
program. It ran fine all night w/o locking up.

Here is what winmsd reports for this PC:
winmsd:
OS Name: Microsoft Windows XP Professional
Version: 5.1.2600 Service Pack 2 Build 2600
Processor: x86 Family 15 Model 4 Stepping 3 GenuineIntel ~3600Mhz
Processor: x86 Family 15 Model 4 Stepping 3 GenuineIntel ~3600Mhz

Okay so this together with what others reported on in this newsgroup
leads to the conclusion that the problem is with the specific software
or hardware configuration of our PC.

So to make sure that no other software is involved we took the PC with
the problem, reset the BIOS to its defaults (which also enables
hyper-threading) and installed Windows XP Professional (SP2) on it (but
no further driver software, etc). We accepted all defaults during the
installation.

Once Windows XP was running we installed Python downloaded from (and
accepted all defaults during the installation):
http://www.python.org/ftp/python/2.4.3/python-2.4.3.msi

And we then ran our Python test program and it hung after less than 15
minutes!

We are now contacting the company that puts that PC together for
further advice.

Olaf

May 10 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4257
by: BlackHawke | last post by:
Hello! I have a java application (a game) which is supposed to run as a server. It is on a dedicated machine with MP capabilities, but currently running 1 Xeon processor with hyperthreading. The hyperthreading is causing the process to receive no more than 50% of the CPU cycles. I've been told that the app needs to be changed to be SMP aware in order to use all hyperthreading.
5
2400
by: Garry Hodgson | last post by:
a colleague of mine has seen an odd problem in some code of ours. we initially noticed it on webware, but in distilling a test case it seems to be strictly a python issue. in the real system, it manifests as webware just locking up, for no apparent reason, until we kill it. we've also had the python interpreter running webware die on occasion. it works fine on our desktop linux and windows machines, but fails on the production hardware. ...
0
2384
by: Shenron | last post by:
Hello, I've seen lots of queries which are sleeping with SHOW PROCESSLIST. Why are they sleeping? How can I prevent this sleeping queries? Because I can't running lots threads at the same time therefore I would prefer have none queries like that. Best Regards,
4
2840
by: Firdousi Farozan Z | last post by:
Hi All, I have a Java multithreaded application, that makes several JNI calls (native code written in C++). I use database locks all through the C++ code for synchronization. With Hyperthreading disabled, I am not seeing any issues with my application. When I enable hyperthreading, my application hangs after a while. Analyzing the issue, I could see that JNI calls just hang without returning, which is causing the application to hang.
1
2307
by: joerg | last post by:
Hello, we investigated a performance-drop while using DB2 V8.1 on a Linux-Server (SuSE - SLES) and Hyperthreading activated. (Dual XEON 2.4 2GB) The intraparallel-option is set and the client establishes 10 independant threads. With hyperthreading activated, the performance drop with factor 2 (4 min -> 8 min). Is there any possibility to configure DB2 to use this feature ?
4
1888
by: Carson | last post by:
Hi, I am now writing a c-code, which is extremely computational extensive. My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc (latest version) to compile with the followings: cc -c -O3 -mcpu=i686 $(FLIST) when i run my program, (a.out), it takes a quite a bit of time to finish,
17
5673
by: Benny Raymond | last post by:
I have a thread that sleeps for 5 minutes once it's finished running a method and then it repeats itself if it's supposed to (bool = true). Prior to 2.0 I was able to resume the thread after marking the bool to false which would cause the thread to finish what it was doing and complete, or to wake up for it's sleep state and not loop back into itself anymore. How do we tell a thread to stop sleeping now that Thread.Resume is obsolete?
3
1479
by: javed74 | last post by:
Hi Guys, We just deployed our asp.net application on Xeon dual processor with Hyperthreading turned on. OS Windows 2003 (Web Edition) .NET Framework 1.1 While stress testing with 1 wp, we get better throughput/RPS then with enabling webGarden - 4 wps. Multiple worker processors with Hyperthreading turned on gives approx. half the performance compared to 1 wp. As per my understanding results should be vice-versa.
3
2380
by: Lars Uffmann | last post by:
I have this wxWidgets OnButtonClick event handler, that apparently holds a lock on all widgets in my form, but this event handler is supposed to end a thread in the background - while that thread is supposed to update widget content. So if I want to wait for the thread to end in the event handler, I have 2 threads waiting on each other - with the one in the background waiting to access the widget content. My current workaround is to...
0
9719
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10624
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3853
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.