breily / twine

simple c multithreading

This URL has Read+Write access

twine / README
100644 64 lines (46 sloc) 1.787 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                                                     
( (
 ) )
( Twine -- An Unassuming Little Threading Library (
 ) -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- )
( ( ) ( ) ) ( ( ) ) (
 ) ) ( ) ( ( ) ) ( ( )
        ( ) ) ) ( ) (
         ) ( )
                         )
 
 )
( Features
 )
 
-- Easy userspace threads
-- Thread preemption after 10ms time slice
-- Mutexes
 
 
 )
( Usage
 )
 
-- Look at thread_test.c to see basic thread usage,
   and mutex_test.c for mutex usage.
 
-- But basically:
    
    twine_init(); // start the library
    twine_create(foo, x); // create a thread
    twine_yield(); // yield control to another thread
 
 
(
 ) Notes
(
 
-- Only compiles on Linux (or anything with the makecontext,
   setcontext, etc. functions, which for some reason are
   missing on OSX).
 
 
(
 ) Improvements
(
 
-- I'm probably not going to do any more work on this, but if I
   were, here are some possible improvements that could be made -
   or you could fork, implement them or others, and I'll pull it
   back.
 
-- Currently the twine_create function only accepts functions that
   return void and have one argument. I know of no way of getting
   around the void return, but you can allow more arguments by
   changing our call to makecontext in thread.c. See
   /usr/includes/ucontext.h for details.
 
-- Figuring out a better slice time (10ms was pretty much picked
   at random), or letting the user set it when he calls twine_init.
 
-- Priority scheduling - I had planned on having it, but I never got
   around to it.