2008-10-12 18:41:06 +02:00
|
|
|
#include <pthread.h>
|
2016-07-09 11:21:54 +02:00
|
|
|
#include <stdio.h>
|
2008-10-12 18:41:06 +02:00
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
void* runner(void*);
|
|
|
|
|
|
|
|
int res = 0;
|
|
|
|
#ifdef __CLASSIC_C__
|
2016-07-09 11:21:54 +02:00
|
|
|
int main()
|
|
|
|
{
|
2008-10-12 18:41:06 +02:00
|
|
|
int ac;
|
2016-07-09 11:21:54 +02:00
|
|
|
char* av[];
|
2008-10-12 18:41:06 +02:00
|
|
|
#else
|
2016-07-09 11:21:54 +02:00
|
|
|
int main(int ac, char* av[])
|
|
|
|
{
|
2008-10-12 18:41:06 +02:00
|
|
|
#endif
|
|
|
|
pthread_t tid[2];
|
|
|
|
pthread_create(&tid[0], 0, runner, (void*)1);
|
|
|
|
pthread_create(&tid[1], 0, runner, (void*)2);
|
2013-03-16 19:13:01 +02:00
|
|
|
|
2016-03-13 13:35:51 +01:00
|
|
|
#if defined(__BEOS__) && !defined(__ZETA__) /* (no usleep on BeOS 5.) */
|
|
|
|
usleep(1); /* for strange behavior on single-processor sun */
|
2008-10-12 18:41:06 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
pthread_join(tid[0], 0);
|
|
|
|
pthread_join(tid[1], 0);
|
2016-07-09 11:21:54 +02:00
|
|
|
if (ac > 1000) {
|
|
|
|
return *av[0];
|
|
|
|
}
|
2008-10-12 18:41:06 +02:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void* runner(void* args)
|
|
|
|
{
|
|
|
|
int cc;
|
2016-07-09 11:21:54 +02:00
|
|
|
for (cc = 0; cc < 10; cc++) {
|
2015-11-17 17:22:37 +01:00
|
|
|
printf("%p CC: %d\n", args, cc);
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
|
|
|
res++;
|
2008-10-12 18:41:06 +02:00
|
|
|
return 0;
|
|
|
|
}
|