/* * Copyright (c) 2003-2005 Hewlett-Packard Development Company, L.P. * * This file is covered by the GNU general public license, version 2. * see COPYING for details.
*/
printf("Testing %s\n", name); if (nthreads > MAX_NTHREADS)
{
fprintf(stderr, "run_parallel: requested too many threads\n");
abort();
}
# ifdef _HPUX_SOURCE /* Default stack size is too small, especially with the 64 bit ABI */ /* Increase it. */ if (pthread_default_stacksize_np(1024*1024, 0) != 0)
{
fprintf(stderr, "pthread_default_stacksize_np failed. " "OK after first call.\n");
} # endif
pthread_attr_init(&attr);
for (i = 0; i < nthreads; ++i)
{ int code = pthread_create(thr + i, &attr, f1, (void *)(long)i); if (code != 0)
{
fprintf(stderr, "pthread_create returned %d, thread %d\n", code, i);
abort();
}
} for (i = 0; i < nthreads; ++i)
{ int code = pthread_join(thr[i], NULL); if (code != 0)
{
fprintf(stderr, "pthread_join returned %d, thread %d\n", code, i);
abort();
}
} if (t())
{
printf("Succeeded\n");
} else
{
fprintf(stderr, "Failed\n");
abort();
} return 0;
} #endif/* USE_PTHREADS */
#ifdef USE_VXTHREADS void * run_parallel(int nthreads, thr_func f1, test_func t, constchar *name)
{ int thr[MAX_NTHREADS]; int i;
printf("Testing %s\n", name); if (nthreads > MAX_NTHREADS)
{
fprintf(stderr, "run_parallel: requested too many threads\n");
taskSuspend(0);
}
for (i = 0; i < nthreads; ++i)
{
thr[i] = taskSpawn((char*) name, 180, 0, 32768, (FUNCPTR) f1, i,
1, 2, 3, 4, 5, 6, 7, 8, 9); if (thr[i] == ERROR)
{
fprintf(stderr, "taskSpawn failed with %d, thread %d\n",
errno, i);
taskSuspend(0);
}
} for (i = 0; i < nthreads; ++i)
{ while (taskIdVerify(thr[i]) == OK)
taskDelay(60);
} if (t())
{
printf("Succeeded\n");
} else
{
fprintf(stderr, "Failed\n");
taskSuspend(0);
} return 0;
} #endif/* USE_VXTHREADS */
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.