URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Only display areas with differences |
Details |
Blame |
View Log
Rev 24 |
Rev 157 |
/* Compiler options:
|
/* Compiler options:
|
#cc: additional_flags=-pthread
|
#cc: additional_flags=-pthread
|
#notarget: cris*-*-elf
|
#notarget: cris*-*-elf
|
|
|
To test sched_yield in the presencs of threads. Core from ex1.c. */
|
To test sched_yield in the presencs of threads. Core from ex1.c. */
|
|
|
#include <stddef.h>
|
#include <stddef.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <pthread.h>
|
#include <pthread.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
|
|
static void *
|
static void *
|
process (void *arg)
|
process (void *arg)
|
{
|
{
|
int i;
|
int i;
|
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
{
|
{
|
if (sched_yield () != 0)
|
if (sched_yield () != 0)
|
abort ();
|
abort ();
|
}
|
}
|
return NULL;
|
return NULL;
|
}
|
}
|
|
|
int
|
int
|
main (void)
|
main (void)
|
{
|
{
|
int retcode;
|
int retcode;
|
pthread_t th_a, th_b;
|
pthread_t th_a, th_b;
|
void *retval;
|
void *retval;
|
|
|
retcode = pthread_create (&th_a, NULL, process, (void *) "a");
|
retcode = pthread_create (&th_a, NULL, process, (void *) "a");
|
if (retcode != 0)
|
if (retcode != 0)
|
abort ();
|
abort ();
|
retcode = pthread_create (&th_b, NULL, process, (void *) "b");
|
retcode = pthread_create (&th_b, NULL, process, (void *) "b");
|
if (retcode != 0)
|
if (retcode != 0)
|
abort ();
|
abort ();
|
retcode = pthread_join (th_a, &retval);
|
retcode = pthread_join (th_a, &retval);
|
if (retcode != 0)
|
if (retcode != 0)
|
abort ();
|
abort ();
|
retcode = pthread_join (th_b, &retval);
|
retcode = pthread_join (th_b, &retval);
|
if (retcode != 0)
|
if (retcode != 0)
|
abort ();
|
abort ();
|
printf ("pass\n");
|
printf ("pass\n");
|
return 0;
|
return 0;
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.