darwin 386 start
This commit is contained in:
parent
6b11fe88cb
commit
110c707dda
6 changed files with 119 additions and 2 deletions
27
src/libthread/test/tcontext.c
Normal file
27
src/libthread/test/tcontext.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#include "../threadimpl.h"
|
||||
#undef exits
|
||||
|
||||
|
||||
ucontext_t c0, c1;
|
||||
char stack[65536];
|
||||
|
||||
void
|
||||
go(void *v)
|
||||
{
|
||||
print("hello, world\n");
|
||||
setcontext(&c0);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
// print("in main\n");
|
||||
getcontext(&c1);
|
||||
c1.uc_stack.ss_sp = stack;
|
||||
c1.uc_stack.ss_size = sizeof stack;
|
||||
makecontext(&c1, go, 1, 0);
|
||||
if(getcontext(&c0) == 0)
|
||||
setcontext(&c1);
|
||||
print("back in main\n");
|
||||
exits(0);
|
||||
}
|
||||
10
src/libthread/test/thello.c
Normal file
10
src/libthread/test/thello.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#include <u.h>
|
||||
#include <libc.h>
|
||||
#include <thread.h>
|
||||
|
||||
void
|
||||
threadmain(int argc, char **argv)
|
||||
{
|
||||
print("hello, world\n");
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue