From e4e54c2ec744e884f6f55c135bea78e815d28d6c Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Thu, 19 Nov 2009 14:32:11 +0200 Subject: libtf: initial commit libtf is to be user-space cooperative threading library similar to State Threads (http://state-threads.sourceforge.net/), but with additional support for multiple cores, using better algorithms and taking advantage of new Linux kernel syscalls such as eventfd, signalfd and epoll (edge-triggered mode). Initial implementation has setjmp based user-space context switching and trivial testcase. Works on Linux/x86. TFbuild uses ideas from different build systems, namely Kbuild, but it's inner workings are quite different. All build files are included (using macro trickery) instead of recursive making. Thus the build dependency graph is complete and should yield good make performance. Also parallel stuff should work. --- test/TFbuild | 3 +++ test/simple1.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 test/TFbuild create mode 100644 test/simple1.c (limited to 'test') diff --git a/test/TFbuild b/test/TFbuild new file mode 100644 index 0000000..d2648ed --- /dev/null +++ b/test/TFbuild @@ -0,0 +1,3 @@ +progs-$(TEST) += simple1 sleep + +LIBS += $(objtree)src/libtf.a diff --git a/test/simple1.c b/test/simple1.c new file mode 100644 index 0000000..65a787c --- /dev/null +++ b/test/simple1.c @@ -0,0 +1,32 @@ +#include +#include + +struct ctx { + int id; +}; + +static void work_fiber(void *ptr) +{ + struct ctx *c = (struct ctx*) ptr; + + printf("Hello%d.1\n", c->id); + tf_yield(); + printf("Hello%d.2\n", c->id); +} + +static void init_fiber(void *ptr) +{ + struct ctx *c; + int i; + + for (i = 0; i < 6; i++) { + c = tf_fiber_create(work_fiber, sizeof(struct ctx)); + c->id = i; + tf_fiber_put(c); + } +} + +int main(int argc, char **argv) +{ + return tf_main(init_fiber); +} -- cgit v1.2.3