mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-23 19:39:53 +08:00
Change getpid() while loop to use sched_yield(), greatly speeds up test.
sched_yield is a requirement for the test but not for our PostgreSQL code, so if it causes a portability problem, we will remove it.
This commit is contained in:
parent
49c8d08bc8
commit
a86c329f99
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.13 2004/04/05 05:43:06 momjian Exp $
|
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.14 2004/04/05 14:12:32 momjian Exp $
|
||||||
*
|
*
|
||||||
* This program tests to see if your standard libc functions use
|
* This program tests to see if your standard libc functions use
|
||||||
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
|
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
|
||||||
@ -83,7 +83,7 @@ defines to your template/$port file before compiling this program.\n\n"
|
|||||||
pthread_create(&thread2, NULL, (void * (*)(void *)) func_call_2, NULL);
|
pthread_create(&thread2, NULL, (void * (*)(void *)) func_call_2, NULL);
|
||||||
|
|
||||||
while (thread1_done == 0 || thread2_done == 0)
|
while (thread1_done == 0 || thread2_done == 0)
|
||||||
getpid(); /* force system call */
|
sched_yield(); /* force system call */
|
||||||
|
|
||||||
printf("Add this to your template/$port file:\n\n");
|
printf("Add this to your template/$port file:\n\n");
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ void func_call_1(void) {
|
|||||||
*/
|
*/
|
||||||
errno1_set = 1;
|
errno1_set = 1;
|
||||||
while (errno2_set == 0)
|
while (errno2_set == 0)
|
||||||
getpid(); /* force system call */
|
sched_yield(); /* force system call */
|
||||||
if (errno != EEXIST)
|
if (errno != EEXIST)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "errno not thread-safe; exiting\n");
|
fprintf(stderr, "errno not thread-safe; exiting\n");
|
||||||
@ -184,7 +184,7 @@ void func_call_2(void) {
|
|||||||
*/
|
*/
|
||||||
errno2_set = 1;
|
errno2_set = 1;
|
||||||
while (errno1_set == 0)
|
while (errno1_set == 0)
|
||||||
getpid(); /* force system call */
|
sched_yield(); /* force system call */
|
||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "errno not thread-safe; exiting\n");
|
fprintf(stderr, "errno not thread-safe; exiting\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user