wespvp@syntegra.com wrote: > On 4/4/04 12:33 AM, "joseph speigle" <joe.speigle@jklh.us> wrote: > > > have you tried adding a volatile keyword to the > > > > int volatile errno1_set = 0; > > int volatile errno2_set = 0; > > > > that should stop while-loop optimizing for cases where the variable is > > modified in a scope the compiler would be ignorant of, and precludes compiler > > while-loop optimization. That would then tell you if it was a while loop > > optimization problem. > > That cures the problem on all systems. What needs to be done to get this > updated in the tip? > > > As for me on RH 8.0 > > > > gcc -v > > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs > > Configured with: ../configure --prefix=/usr --mandir=/usr/share/man > > --infodir=/usr/share/info --enable-shared --enable-threads=posix > > --disable-checking --host=i386-redhat-linux --with-system-zlib > > --enable-__cxa_atexit > > Thread model: posix > > gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) > > > > sorry, they all run yes/no/no > > I don't know what is different, but I've tried it on RH 7.2, RH AS 3.0, and > Mac OS X. All hang in an infinite loop with the tip version of > thread_test.c, and all work if I add 'volatile' to the definitions of > errno1_set and errno2_set. > > There's still the question of which version of the program is giving the > right answers - the 7.4.2 version or the tip version? I have applied the following patch to CVS head which does a getpid() in the loop, rather than nothing. getpid() should force a system call, which will make it more likely for the other thread to get CPU time and complete its tests. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Index: thread_test.c =================================================================== RCS file: /cvsroot/pgsql-server/src/tools/thread/thread_test.c,v retrieving revision 1.9 retrieving revision 1.10 diff -c -c -r1.9 -r1.10 *** thread_test.c 28 Mar 2004 02:37:31 -0000 1.9 --- thread_test.c 4 Apr 2004 17:23:54 -0000 1.10 *************** *** 105,111 **** /* wait for other thread to set errno */ errno1_set = 1; while (errno2_set == 0) ! /* loop */; if (errno != EEXIST) { fprintf(stderr, "errno not thread-safe; exiting\n"); --- 105,111 ---- /* wait for other thread to set errno */ errno1_set = 1; while (errno2_set == 0) ! getpid(); /* force system call */ if (errno != EEXIST) { fprintf(stderr, "errno not thread-safe; exiting\n"); *************** *** 128,135 **** passwd_p1 = NULL; /* force thread-safe failure report */ } ! hostent_p1 = gethostbyname("yahoo.com"); ! p = gethostbyname("slashdot.org"); if (hostent_p1 != p) { printf("Your gethostbyname() changes the static memory area between calls\n"); --- 128,135 ---- passwd_p1 = NULL; /* force thread-safe failure report */ } ! hostent_p1 = gethostbyname("www.yahoo.com"); ! p = gethostbyname("www.weather.com"); if (hostent_p1 != p) { printf("Your gethostbyname() changes the static memory area between calls\n"); *************** *** 151,157 **** /* wait for other thread to set errno */ errno2_set = 1; while (errno1_set == 0) ! /* loop */; if (errno != ENOENT) { fprintf(stderr, "errno not thread-safe; exiting\n"); --- 151,157 ---- /* wait for other thread to set errno */ errno2_set = 1; while (errno1_set == 0) ! getpid(); /* force system call */ if (errno != ENOENT) { fprintf(stderr, "errno not thread-safe; exiting\n"); *************** *** 174,181 **** passwd_p2 = NULL; /* force thread-safe failure report */ } ! hostent_p2 = gethostbyname("google.com"); ! p = gethostbyname("postgresql.org"); if (hostent_p2 != p) { printf("Your gethostbyname() changes the static memory area between calls\n"); --- 174,181 ---- passwd_p2 = NULL; /* force thread-safe failure report */ } ! hostent_p2 = gethostbyname("www.google.com"); ! p = gethostbyname("www.postgresql.org"); if (hostent_p2 != p) { printf("Your gethostbyname() changes the static memory area between calls\n");
---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org