PERFORCE change 75713 for review
David Xu
davidxu at FreeBSD.org
Fri Apr 22 06:04:56 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=75713
Change 75713 by davidxu at davidxu_tiger on 2005/04/22 13:04:41
thr_new refine.
Affected files ...
.. //depot/projects/davidxu_thread/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#13 edit
.. //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#14 edit
.. //depot/projects/davidxu_thread/src/sys/kern/kern_thr.c#18 edit
.. //depot/projects/davidxu_thread/src/sys/kern/kern_thread.c#10 edit
.. //depot/projects/davidxu_thread/src/sys/sys/thr.h#9 edit
Differences ...
==== //depot/projects/davidxu_thread/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#13 (text+ko) ====
@@ -747,6 +747,7 @@
}
if (ourstatus->value.sig == TARGET_SIGNAL_TRAP)
check_event(ret);
+#if 0
/* this is a hack, if an event won't cause gdb to stop, for example,
SIGARLM, gdb resumes the process immediatly without setting
inferior_ptid to the new thread returned here, this is a bug
@@ -757,6 +758,7 @@
delete_thread (inferior_ptid);
inferior_ptid = ret;
}
+#endif
}
return (ret);
==== //depot/projects/davidxu_thread/src/lib/libthr/thread/thr_create.c#14 (text+ko) ====
@@ -53,8 +53,6 @@
_pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
{
- ucontext_t uc;
- sigset_t sigmask, oldsigmask;
struct pthread *curthread, *new_thread;
struct thr_param param;
int ret = 0, locked;
@@ -71,6 +69,8 @@
if ((new_thread = _thr_alloc(curthread)) == NULL)
return (EAGAIN);
+ memset(¶m, 0, sizeof(param));
+
if (attr == NULL || *attr == NULL)
/* Use the default thread attributes: */
new_thread->attr = _pthread_attr_default;
@@ -109,13 +109,6 @@
new_thread->arg = arg;
new_thread->cancelflags = PTHREAD_CANCEL_ENABLE |
PTHREAD_CANCEL_DEFERRED;
-#if 0
- getcontext(&uc);
- SIGFILLSET(uc.uc_sigmask);
- uc.uc_stack.ss_sp = new_thread->attr.stackaddr_attr;
- uc.uc_stack.ss_size = new_thread->attr.stacksize_attr;
- makecontext(&uc, (void (*)(void))thread_start, 1, new_thread);
-#endif
/*
* Check if this thread is to inherit the scheduling
* attributes from its parent:
@@ -148,17 +141,7 @@
if (new_thread->attr.suspend == THR_CREATE_SUSPENDED)
new_thread->flags = THR_FLAGS_SUSPENDED;
new_thread->state = PS_RUNNING;
-#if 0
- /*
- * Thread created by thr_create() inherits currrent thread
- * sigmask, however, before new thread setup itself correctly,
- * it can not handle signal, so we should masks all signals here.
- */
- SIGFILLSET(sigmask);
- SIGDELSET(sigmask, SIGTRAP);
- __sys_sigprocmask(SIG_SETMASK, &sigmask, &oldsigmask);
- new_thread->sigmask = oldsigmask;
-#endif
+
/* Add the new thread. */
_thr_link(curthread, new_thread);
/* Return thread pointer eariler so that new thread can use it. */
@@ -168,25 +151,19 @@
locked = 1;
} else
locked = 0;
- param.start_func = thread_start;
+ param.start_func = (void (*)(void *)) thread_start;
param.arg = new_thread;
param.stack_base = new_thread->attr.stackaddr_attr;
param.stack_size = new_thread->attr.stacksize_attr;
- param.tls_base = new_thread->tcb;
+ param.tls_base = (char *)new_thread->tcb;
param.tls_size = sizeof(struct tcb);
- param.tls_seg = 0;
param.child_tid = &new_thread->tid;
param.parent_tid = &new_thread->tid;
- param.user_crit = 0;
param.flags = 0;
if (new_thread->attr.flags & PTHREAD_SCOPE_SYSTEM)
param.flags |= THR_SYSTEM_SCOPE;
/* Schedule the new thread. */
ret = thr_new(¶m, sizeof(param));
-#if 0
- ret = thr_create(&uc, &new_thread->tid, 0);
- __sys_sigprocmask(SIG_SETMASK, &oldsigmask, NULL);
-#endif
if (ret != 0) {
if (locked)
THR_THREAD_UNLOCK(curthread, new_thread);
@@ -239,12 +216,6 @@
static void
thread_start(struct pthread *curthread)
{
-#if 0
- _tcb_set(curthread->tcb);
-
- /* Thread was created with all signals blocked, unblock them. */
- __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL);
-#endif
if (curthread->flags & THR_FLAGS_NEED_SUSPEND)
_thr_suspend_check(curthread);
==== //depot/projects/davidxu_thread/src/sys/kern/kern_thr.c#18 (text+ko) ====
@@ -89,7 +89,7 @@
struct thr_param param;
int error;
- if (uap->param_size != sizeof(param))
+ if (uap->param_size < sizeof(param))
return (EINVAL);
if ((error = copyin(uap->param, ¶m, sizeof(param))))
return (error);
==== //depot/projects/davidxu_thread/src/sys/kern/kern_thread.c#10 (text+ko) ====
==== //depot/projects/davidxu_thread/src/sys/sys/thr.h#9 (text+ko) ====
@@ -42,11 +42,10 @@
size_t stack_size; /* stack size. */
char *tls_base; /* tls base address. */
size_t tls_size; /* tls size. */
- int tls_seg; /* which seg is to set for tls. */
long *child_tid; /* address to store new TID. */
long *parent_tid; /* parent accesses the new TID here. */
- int *user_crit; /* reserved */
- int flags;
+ int flags; /* thread flags. */
+ void *spare[4]; /* TODO: cpu affinity mask etc. */
};
/*
More information about the p4-projects
mailing list