|
|
Up |
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 20:28
Here's a corrected version of patch #7 that both fixes the spelling of
_thread_sys_kill() and makes it apply cleanly after patch #5. (Picking
apart larger patches can be a tricky exercise...)
I should note that all these patches should apply to -current.
Philip Guenther
Redirect kill(getpid(), sig) to the current thread. Make
pthread_suspend_np(main_thread) work.
|
| Show full article (2.73Kb) |
|
| |
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 19:54
On Sat, May 3, 2008 at 8:02 PM, Philip Guenther gmail.com> wrote:
...
> - if (kill(thread->tid, SIGCONT) == -1)
> + if (_thread_sys_kil(thread->tid, SIGCONT) == -1)
That should be _thread_sys_kill, with two ells, of course. (Thanks to
David Higgs for catching that.)
Philip
|
| |
|
| |
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 19:05
Redirect kill(getpid(), sig) to the current thread. Make
pthread_suspend_np(main_thread) work.
Philip Guenther
Index: lib/librthread/rthread.c
===================================================================
RCS file: /cvs/src/lib/librthread/rthread.c,v
retrieving revision 1.34
diff -u -r1.34 rthread.c
--- lib/librthread/rthread.c 18 May 2007 14:36:17 -0000 1.34
+++ lib/librthread/rthread.c 4 May 2008 01:58:24 -0000
@@ -319,7 +319,7 @@
* signal delivery is implemented, this is not a race.
*/
if (thread->attr.create_suspended)
- kill(thread->tid, SIGSTOP);
+ _thread_sys_kill(thread->tid, SIGSTOP);
_spinunlock(&_thread_lock);
|
| Show full article (2.45Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 18:54
Fix the handling of application-specified thread stacks: don't try to
set a guard page and don't munmap the stack when the thread exits.
Philip Guenther
Index: lib/librthread/rthread_np.c
===================================================================
RCS file: /cvs/src/lib/librthread/rthread_np.c,v
retrieving revision 1.5
diff -u -r1.5 rthread_np.c
--- lib/librthread/rthread_np.c 8 Jul 2007 01:53:46 -0000 1.5
+++ rthread_np.c 13 Apr 2008 05:32:32 -0000
@@ -58,17 +58,12 @@
int
pthread_stackseg_np(pthread_t thread, stack_t *sinfo)
{
- char *base;
size_t pgsz;
int ret;
struct rlimit rl;
|
| Show full article (2.90Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 18:52
This changes the thrsigdivert() system call to have the arguments and
behavior of sigtimedwait(), then (trivially) implements sigwait() from
that in librthread. This simplifies the sigwait() processing by
eliminating the altering of the signal handlers done by the existing
implementation. (The existing version doesn't work at all if the signal
occurs before the thrsleep() call.)
(Yeah, the system call should probably be renamed, but that would require
non-backwards compatible libc change, so it would make testing by mortals
a _real_ pain.)
As mentioned in patch #3, this is not a complete solution, as there's no
way to tell the difference between a signal pending for the process and a
signal pending for the main thread, so sigwait() in other threads will
either handle both or neither of those. This implementation lets
sigwait() handle both (the existing one handles neither). Both is better
than neither, as otherwise sigwait() in threads other than the main thread
would be almost useless.
Philip Guenther
Index: sys/kern/init_sysent.c
===================================================================
RCS file: /cvs/src/sys/kern/init_sysent.c,v
retrieving revision 1.103
diff -u -r1.103 init_sysent.c
--...
|
| Show full article (9.77Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 18:44
Change "long p_thrslpid;" in struct proc to "void *p_thrslparg;" to
eliminate pointer->long punning in sys_thrsleep() and sys_thrwakeup().
(This is required for the next patch (#5) too.)
Philip Guenther
Index: sys/sys/proc.h
===================================================================
RCS file: /cvs/src/sys/sys/proc.h,v
retrieving revision 1.102
diff -u -r1.102 proc.h
--- sys/sys/proc.h 28 Nov 2007 20:07:36 -0000 1.102
+++ sys/sys/proc.h 20 Apr 2008 22:06:12 -0000
@@ -184,7 +184,7 @@
pid_t p_oppid; /* Save parent pid during ptrace. XXX */
int p_dupfd; /* Sideways return value from filedescopen. XXX */
- long p_thrslpid; /* for thrsleep syscall */
+ void *p_thrslparg; /* for thrsleep and thrsigdivert syscalls */
/* scheduling */
Index: sys/kern/kern_synch.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.83
diff -u -r1.83 kern_synch...
|
| Show full article (2.60Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 18:38
Move the functionality of psignal() to a new function ptsignal()
that takes an additional argument "thread" that indicates whether
the signal is
0) for the process as a whole (and can be diverted via sigwait())
1) for a particular thread, but should be propagated (e.g., to kill
the entire process) if not handled by that thread, or
-1) for a particular thread and must not be propagated
The handling of signals that stop or resume the process is changed to use
the last of those when propagating the signal to the other threads in the
process, so that they don't try to propagated it back in an infinite loop.
Ditto when the process is exiting and the remaining threads need to be
forcibly killed.
The middle value is used when a signal is directed to a particular thread:
traps, SIGPIPE, and pthread_kill().
Finally, psignal() becomes just a wrapper around ptsignal() that passes
zero ("signal to process") as the final argument.
|
| Show full article (7.02Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 18:33
In fork1(), move up the initialization of the child's p_flag member
above where the P_THREAD bit is set. (As is, that flag doesn't
last to outside fork1().) Then, change proc_zap() to only free the
process structure when the main thread is being zapped instead of
whenever the process's thread list is empty. This fixes a crash
where the process structure is freed twice when a process with
multiple threads exits.
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.93
diff -u -r1.93 kern_fork.c
--- sys/kern/kern_fork.c 10 Oct 2007 15:53:53 -0000 1.93
+++ sys/kern/kern_fork.c 20 Apr 2008 22:06:06 -0000
@@ -224,6 +224,7 @@
p2->p_stat = SIDL; /* protect against others */
p2->p_exitsig = exitsig;
+ p2->p_flag = 0;
#ifdef RTHREADS
if (flags & FORK_THREAD) {
@@ -260,7 +261,6 @@
* Increase reference counts on shared objects.
* The p_stats and p_sigacts substructs are set in vm_fork.
*/
- p2->p_flag...
|
| Show full article (1.89Kb) |
|
no comments
|
|
  |
Author: Philip GuentherPhilip Guenther
Date: May 3, 2008 17:28
Share signal action between threads.
Index: sys/kern/kern_fork.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.93
diff -u -r1.93 kern_fork.c
--- sys/kern/kern_fork.c 10 Oct 2007 15:53:53 -0000 1.93
+++ sys/kern/kern_fork.c 20 Apr 2008 22:06:06 -0000
@@ -143,7 +143,7 @@
flags |= FORK_SHAREVM;
#ifdef RTHREADS
if (rforkflags & RFTHREAD)
- flags |= FORK_THREAD;
+ flags |= FORK_THREAD | FORK_SIGHAND;
#endif
return (fork1(p, SIGCHLD, flags, NULL, 0, NULL, NULL, retval, NULL));
Here's a test program.
|
| Show full article (1.52Kb) |
|
no comments
|
|
  |
|
|
  |
Author: Martin ReindlMartin Reindl
Date: May 3, 2008 14:28
I would appreciate if people could test this diff for me on either arm,
sgi or landisk. Please send reports to me directly. Thank you.
Index: arm/arm/arm32_machdep.c
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/arm32_machdep.c,v
retrieving revision 1.28
diff -u -p -r1.28 arm32_machdep.c
--- arm/arm/arm32_machdep.c 23 Mar 2008 17:05:41 -0000 1.28
+++ arm/arm/arm32_machdep.c 3 May 2008 21:16:52 -0000
@@ -273,7 +273,7 @@ cpu_startup()
*/
|
| Show full article (6.28Kb) |
|
no comments
|
|
|
|
|
|
|