mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-16 21:36:35 +00:00
1bc541f213
Original commit message from CVS: The core code from pth has been taken out and included in gstreamer. This code is documented, more or less, in http://www-124.ibm.com/pthreads/docs/rse-pmt.ps. This code is designed to replace cothreads.[ch], eventually.
36 lines
611 B
C
36 lines
611 B
C
#include "pth_p.h"
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
|
|
pth_mctx_t main_context;
|
|
|
|
void thread_1 (char *str)
|
|
{
|
|
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);
|
|
}
|
|
|