signal handling, add prototype for pthreadinit
This commit is contained in:
parent
43db87f1fc
commit
e1dc7e4511
3 changed files with 19 additions and 4 deletions
|
|
@ -101,7 +101,7 @@ _threadsetproc(Proc *p)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pthreadinit(void)
|
_pthreadinit(void)
|
||||||
{
|
{
|
||||||
pthread_key_create(&prockey, 0);
|
pthread_key_create(&prockey, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ scheduler(void *v)
|
||||||
|
|
||||||
p = v;
|
p = v;
|
||||||
setproc(p);
|
setproc(p);
|
||||||
print("s %p %d\n", p, gettid());
|
// print("s %p %d\n", p, gettid());
|
||||||
p->tid = pthread_self();
|
p->tid = pthread_self();
|
||||||
pthread_detach(p->tid);
|
pthread_detach(p->tid);
|
||||||
lock(&p->lock);
|
lock(&p->lock);
|
||||||
|
|
@ -503,6 +503,13 @@ threadmainstart(void *v)
|
||||||
threadmain(threadargc, threadargv);
|
threadmain(threadargc, threadargv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern Jmp *(*_notejmpbuf)(void);
|
||||||
|
static Jmp*
|
||||||
|
threadnotejmp(void)
|
||||||
|
{
|
||||||
|
return &proc()->sigjmp;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
@ -524,8 +531,9 @@ main(int argc, char **argv)
|
||||||
_wunlock = threadwunlock;
|
_wunlock = threadwunlock;
|
||||||
_rsleep = threadrsleep;
|
_rsleep = threadrsleep;
|
||||||
_rwakeup = threadrwakeup;
|
_rwakeup = threadrwakeup;
|
||||||
|
_notejmpbuf = threadnotejmp;
|
||||||
|
|
||||||
pthreadinit();
|
_pthreadinit();
|
||||||
p = procalloc();
|
p = procalloc();
|
||||||
if(mainstacksize == 0)
|
if(mainstacksize == 0)
|
||||||
mainstacksize = 65536;
|
mainstacksize = 65536;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,12 @@ typedef struct Context Context;
|
||||||
typedef struct Proc Proc;
|
typedef struct Proc Proc;
|
||||||
typedef struct _Procrendez _Procrendez;
|
typedef struct _Procrendez _Procrendez;
|
||||||
|
|
||||||
|
typedef struct Jmp Jmp;
|
||||||
|
struct Jmp
|
||||||
|
{
|
||||||
|
p9jmp_buf b;
|
||||||
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
STACK = 8192
|
STACK = 8192
|
||||||
|
|
@ -54,6 +60,7 @@ struct Proc
|
||||||
_Procrendez runrend;
|
_Procrendez runrend;
|
||||||
Context schedcontext;
|
Context schedcontext;
|
||||||
void *udata;
|
void *udata;
|
||||||
|
Jmp sigjmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Proc *xxx;
|
extern Proc *xxx;
|
||||||
|
|
@ -67,4 +74,4 @@ extern Proc *_threadproc(void);
|
||||||
extern void _threadsetproc(Proc*);
|
extern void _threadsetproc(Proc*);
|
||||||
extern int _threadlock(Lock*, int, ulong);
|
extern int _threadlock(Lock*, int, ulong);
|
||||||
extern void _threadunlock(Lock*, ulong);
|
extern void _threadunlock(Lock*, ulong);
|
||||||
|
extern void _pthreadinit(void);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue