gstreamer/gst/cothreads/test-pth.c
Andy Wingo 259c8c394c some compile fixes, api changes, and i added the ability to create new chunks on the stack, which can extend the main...
Original commit message from CVS:
some compile fixes, api changes, and i added the ability to create new chunks on the
stack, which can extend the main thread's stack up to 8M under linuxthreads. thanks
to billh for the {set,get}rlimit tip.

on the other hand, there's a nasty bug in cothreads when they are run without gthreads
that i'm still tracking down. that's the last bug though, at this point.

the commit is to syn the repository with my working copy before moving cothreads to a
separate module.
2002-02-02 19:07:10 +00:00

36 lines
606 B
C

#include "pth_p.h"
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
pth_mctx_t main_context;
void thread_1 (void)
{
printf ("sleeping 5s in thread 1...\n");
sleep (5);
printf ("returning to thread 0\n");
pth_mctx_restore (&main_context);
}
int main (int argc, char *argv[])
{
pth_mctx_t ctx;
char *skaddr;
pth_mctx_save (&main_context);
skaddr = malloc (64 * 1024);
pth_mctx_set (&ctx, thread_1, skaddr, skaddr + 64 * 1024);
printf ("switching to thread 1...");
pth_mctx_switch (&main_context, &ctx);
printf ("back now, exiting.\n");
exit (0);
}