aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/threadimpl.h
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2004-12-25 21:57:50 +0000
committerrsc <devnull@localhost>2004-12-25 21:57:50 +0000
commit619085f0b4a85104ef6c7496f9ce1f46e9b17c82 (patch)
tree9959c15a14c44e8c8fe38f78bbcbbb576d23b2aa /src/libthread/threadimpl.h
parent1544f90960275dc9211bde30329c3258e0e1bf38 (diff)
downloadplan9port-619085f0b4a85104ef6c7496f9ce1f46e9b17c82.tar.gz
plan9port-619085f0b4a85104ef6c7496f9ce1f46e9b17c82.tar.bz2
plan9port-619085f0b4a85104ef6c7496f9ce1f46e9b17c82.zip
more new libthread
Diffstat (limited to 'src/libthread/threadimpl.h')
-rw-r--r--src/libthread/threadimpl.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/libthread/threadimpl.h b/src/libthread/threadimpl.h
new file mode 100644
index 00000000..9f70b0e0
--- /dev/null
+++ b/src/libthread/threadimpl.h
@@ -0,0 +1,70 @@
+#include <ucontext.h>
+
+typedef struct Context Context;
+typedef struct Proc Proc;
+typedef struct _Procrendez _Procrendez;
+
+enum
+{
+ STACK = 8192
+};
+
+struct Context
+{
+ ucontext_t uc;
+};
+
+struct _Thread
+{
+ _Thread *next;
+ _Thread *prev;
+ _Thread *allnext;
+ _Thread *allprev;
+ Context context;
+ uint id;
+ uchar *stk;
+ uint stksize;
+ int exiting;
+ void (*startfn)(void*);
+ void *startarg;
+ Proc *proc;
+ char name[256];
+ char state[256];
+};
+
+struct _Procrendez
+{
+ Lock *l;
+ int asleep;
+ pthread_cond_t cond;
+};
+
+extern void _procsleep(_Procrendez*);
+extern void _procwakeup(_Procrendez*);
+
+struct Proc
+{
+ pthread_t tid;
+ Lock lock;
+ _Thread *thread;
+ _Threadlist runqueue;
+ _Threadlist allthreads;
+ uint nthread;
+ uint sysproc;
+ _Procrendez runrend;
+ Context schedcontext;
+ void *udata;
+};
+
+extern Proc *xxx;
+#define proc() _threadproc()
+#define setproc(p) _threadsetproc(p)
+
+extern void _procstart(Proc*, void (*fn)(void*));
+extern _Thread *_threadcreate(Proc*, void(*fn)(void*), void*, uint);
+extern void _threadexit(void);
+extern Proc *_threadproc(void);
+extern void _threadsetproc(Proc*);
+extern int _threadlock(Lock*, int, ulong);
+extern void _threadunlock(Lock*, ulong);
+