| [ Return to Bugs & Features | Roadmap 1.1 | SVN ⇄ GIT ]
STR #1138
Application: | FLTK Library |
Status: | 1 - Closed w/Resolution |
Priority: | 2 - Low, e.g. a documentation error or undocumented side-effect |
Scope: | 2 - Specific to an operating system |
Subsystem: | MacOS |
Summary: | pthreads support not activated though working very well in mac os x |
Version: | 1.1-current |
Created By: | fabien |
Assigned To: | mike |
Fix Version: | 1.1-current (SVN: v4740) |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | fabien 11:48 Jan 05, 2006 |
| 1)
in ./src/config.h #define HAVE_PTHREAD 1 #define HAVE_PTHREAD_H 1
are missing after running ./configure
though it does work very well and pthread ARE supported by Darwin (at least in mac os 10.4)
2) Bug & Fix in Mac OSX AND Win32 for the threads example:
Under Mac OS X (and also in Windows XP), the threads example bugs if you let it run a while ... the prime number in the multithreaded browser are erroneous.
This comes from the non-atomicity of the increment of loop variable n, simply protect the increment as follows (replaces the prime_func loop):
// very simple prime number calculator ! for (; ; ) { int p; int hn = (int)sqrt((double)n); for (p=3; p<=hn; p+=2) if ( n%p == 0 ) break; if (p >= hn) { char s[128]; sprintf(s, "%d", n); Fl::lock(); browser->add(s); browser->bottomline(browser->size()); if (n > value->value()) value->value(n); n+= step; Fl::unlock(); Fl::awake((void*) (browser == browser1? p:0)); // Cause the browser to redraw ... } else { Fl::lock(); n+= step; Fl::unlock(); } } | |
|
#2 | mike 12:10 Jan 05, 2006 |
| PLEASE RE-TEST WITH THE 1.1.7 RELEASE CANDIDATE!
Also, threading is not enabled by default - you MUST provide the "--enable-threads" configure option to enable it! | |
|
#3 | mike 12:15 Jan 05, 2006 |
| Also, regarding #2, "n" is a local variable referenced by a single thread, so there are no atomicity issues. It *is* possible for the primes to be added out-of-order, but that is not the point of the demo... | |
|
#4 | matt 15:07 Jan 05, 2006 |
| Testing with the current RC, threading works very well on OS X 10.4.3. It is neccessary to configure with --enable-threads, just like Mike stated.
Should threads be enabled by default on Mac? It will change the implementation form using fd's to using pthreads. | |
|
#5 | mike 16:54 Jan 05, 2006 |
| No, we'll enable threading by default in 2.0, but doing it in 1.1.x might break binary compatibility. | |
|
#6 | mike 08:03 Jan 06, 2006 |
| [copy of post to fltk.bugs]
Thanks for the explanation of point #1.
But No , what I was trying to say in #2 had nothing to do with the out of order : the display is altered after approx 30secs (depending on your machine/platform) and display of some VALUES are about -2147483647.
So the value of the prime number in itself is incorrect.
And I experimented this bug with OS X 10.4.3/fltk 1.1.7rc2 and Windows XP Pro SP2/fltk, 1.1.7rc2
The patch is suggest correct this.
Sorry for my english, Fabien. | |
|
#7 | mike 08:56 Jan 06, 2006 |
| [Please post your responses to the STR - that will ensure we keep a log of all the issues... Thanks!]
I've tested on multiple platforms - this problem *only* happens on MacOS X 10.4 (and not on previous MacOS X releases). I've added your workaround since I'm not able to otherwise eliminate the problem, but this is a (rather serious) MacOS X threading bug - the local variables are supposed to exist in separate address spaces, but even setting the stack size attribute in the pthread_create() call does not "fix" the problem. | |
|
#8 | fabien 10:07 Jan 06, 2006 |
| I totally agree with you mike and this is really weird but please believe me when I said it also happened in Windows XP but after a rather long period of time : I noticed it this week with the candidate release. | |
|
#9 | mike 10:55 Jan 13, 2006 |
| OK, this is fixed... | |
[ Return to Bugs & Features ]
|
| |