summaryrefslogtreecommitdiffstats
path: root/DESIGN
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-11-19 14:32:11 +0200
committerTimo Teras <timo.teras@iki.fi>2009-11-24 08:12:45 +0200
commite4e54c2ec744e884f6f55c135bea78e815d28d6c (patch)
tree3278c0bdb3eedc47eaf71ef53b9ff849cb136593 /DESIGN
downloadlibtf-e4e54c2ec744e884f6f55c135bea78e815d28d6c.tar.bz2
libtf-e4e54c2ec744e884f6f55c135bea78e815d28d6c.tar.xz
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.
Diffstat (limited to 'DESIGN')
-rw-r--r--DESIGN19
1 files changed, 19 insertions, 0 deletions
diff --git a/DESIGN b/DESIGN
new file mode 100644
index 0000000..2ffc535
--- /dev/null
+++ b/DESIGN
@@ -0,0 +1,19 @@
+SCHEDULER
+- 4-heap (or 2-heap) with linked nodes
+- epoll
+- edge-triggered monitoring for file i/o (no syscalls to modify fdset)
+- signalfd for signal handling
+- eventfd for thread pool wakeup
+
+FIBERS
+- timer node on fiber control data (for delayed heapify; and reuse on timeouts)
+- fd, signal, pid wait struct on stack of wait function
+- fiber_kill can interrupt wait
+
+SCHEDULER <-> THREAD POOL
+- scheduler queues to thread pool array fifo queue,
+ - semaphore protects threads so no underqueueing happens
+ - eventfd notifies scheduler when queue has free space again
+ - head/tail updated atomically and item position recovered
+- thread pool atomically pushes to resume atomic stack and sets eventfd
+ - scheduler thread atomically pops all and updates fiber states