URL
https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 24 |
Rev 157 |
/* Check that TRT happens when we reach the #threads implementation limit.
|
/* Check that TRT happens when we reach the #threads implementation limit.
|
#notarget: cris*-*-elf
|
#notarget: cris*-*-elf
|
*/
|
*/
|
|
|
#include <stddef.h>
|
#include <stddef.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <limits.h>
|
#include <limits.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <sched.h>
|
#include <sched.h>
|
#include <errno.h>
|
#include <errno.h>
|
#include <sys/types.h>
|
#include <sys/types.h>
|
#include <sys/wait.h>
|
#include <sys/wait.h>
|
|
|
int
|
int
|
process (void *arg)
|
process (void *arg)
|
{
|
{
|
int i;
|
int i;
|
|
|
for (i = 0; i < 500; i++)
|
for (i = 0; i < 500; i++)
|
if (sched_yield ())
|
if (sched_yield ())
|
abort ();
|
abort ();
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
int
|
int
|
main (void)
|
main (void)
|
{
|
{
|
int pid;
|
int pid;
|
int i;
|
int i;
|
int stacksize = 16384;
|
int stacksize = 16384;
|
|
|
for (i = 0; i < 1000; i++)
|
for (i = 0; i < 1000; i++)
|
{
|
{
|
char *stack = malloc (stacksize);
|
char *stack = malloc (stacksize);
|
if (stack == NULL)
|
if (stack == NULL)
|
abort ();
|
abort ();
|
|
|
pid = clone (process, (char *) stack + stacksize - 64,
|
pid = clone (process, (char *) stack + stacksize - 64,
|
(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
|
(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND)
|
| SIGCHLD, "ab");
|
| SIGCHLD, "ab");
|
if (pid <= 0)
|
if (pid <= 0)
|
{
|
{
|
/* FIXME: Read sysconf instead of magic number. */
|
/* FIXME: Read sysconf instead of magic number. */
|
if (i < 60)
|
if (i < 60)
|
{
|
{
|
fprintf (stderr, "Bad clone %d\n", pid);
|
fprintf (stderr, "Bad clone %d\n", pid);
|
abort ();
|
abort ();
|
}
|
}
|
|
|
if (errno == EAGAIN)
|
if (errno == EAGAIN)
|
{
|
{
|
printf ("pass\n");
|
printf ("pass\n");
|
exit (0);
|
exit (0);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
|
abort ();
|
abort ();
|
}
|
}
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.