Subject: kernel signal struct change
To: None <tech-kern@netbsd.org>
From: Jaromír Dolecek <dolecek@ics.muni.cz>
List: tech-kern
Date: 12/13/2000 22:26:09
Hi,
inspired by kern/10981, I'd like to split struct sigacts, so that
only the sighandler array may be shared among threads. This seems
to be the right thing to do, since the rest of struct sigacts is not
actually sharable between threads.
I think that the per-process stuff should be in embedded into
struct proc directly, not allocated separately. While changing this,
I also think that other signal related stuff in struct proc should be put
together into single struct.
I've added struct sigctx, which contains all signal related per-process
stuff. I'm including patch to sys/proc.h, sys/signalvar.h; other
changes in kernel sources are just mechanical.
Does this seem OK ? I'm running with those changes right now; it helped
with the problem mentioned in kern/10981, though there is no change
in the other linux emulation related problems.
Jaromir
XXXX
Index: sys/proc.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/proc.h,v
retrieving revision 1.116
diff -u -r1.116 proc.h
--- sys/proc.h 2000/12/11 05:29:03 1.116
+++ sys/proc.h 2000/12/13 19:20:11
@@ -54,6 +54,7 @@
#include <sys/lock.h>
#include <sys/queue.h>
#include <sys/callout.h>
+#include <sys/signalvar.h>
/*
* One structure allocated per session.
@@ -138,7 +139,7 @@
struct pstats *p_stats; /* Accounting/statistics (PROC ONLY). */
struct plimit *p_limit; /* Process limits. */
struct vmspace *p_vmspace; /* Address space. */
- struct sigacts *p_sigacts; /* Signal actions, state (PROC ONLY). */
+ struct sigacts *p_sigacts; /* Process sigactions (state is below)*/
#define p_ucred p_cred->pc_ucred
#define p_rlimit p_limit->pl_rlimit
@@ -184,9 +185,6 @@
int p_traceflag; /* Kernel trace points. */
struct file *p_tracep; /* Trace to file */
- sigset_t p_siglist; /* Signals arrived but not delivered. */
- char p_sigcheck; /* May have deliverable signals. */
-
struct vnode *p_textvp; /* Vnode of executable. */
int p_locks; /* DEBUG: lockmgr count of held locks */
@@ -200,11 +198,9 @@
#define p_endzero p_startcopy
/* The following fields are all copied upon creation in fork. */
-#define p_startcopy p_sigmask
+#define p_startcopy p_sigctx.ps_startcopy
- sigset_t p_sigmask; /* Current signal mask. */
- sigset_t p_sigignore; /* Signals being ignored. */
- sigset_t p_sigcatch; /* Signals being caught by user. */
+ struct sigctx p_sigctx; /* Signal state. */
u_char p_priority; /* Process priority. */
u_char p_usrpri; /* User-priority based on p_cpu and p_nice. */
Index: sys/signalvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/sys/signalvar.h,v
retrieving revision 1.26
diff -u -r1.26 signalvar.h
--- sys/signalvar.h 2000/11/15 21:13:58 1.26
+++ sys/signalvar.h 2000/12/13 19:20:12
@@ -44,18 +44,33 @@
*/
/*
- * Process signal actions and state, needed only within the process
- * (not necessarily resident).
+ * Process signal actions, possibly shared between threads.
*/
-struct sigacts {
- struct sigaction ps_sigact[NSIG]; /* disposition of signals */
+struct sigacts {
+ struct sigaction sa_sigact[NSIG]; /* disposition of signals */
+
+ int sa_refcnt; /* reference count */
+};
+
+/*
+ * Process signal state.
+ */
+struct sigctx {
+ /* This needs to be zeroed on fork */
+ sigset_t ps_siglist; /* Signals arrived but not delivered. */
+ char ps_sigcheck; /* May have deliverable signals. */
+
+ /* This should be copied on fork */
+#define ps_startcopy ps_sigstk
struct sigaltstack ps_sigstk; /* sp & on stack state variable */
sigset_t ps_oldmask; /* saved mask from before sigpause */
int ps_flags; /* signal flags, below */
int ps_sig; /* for core dump/debugger XXX */
long ps_code; /* for core dump/debugger XXX */
void *ps_sigcode; /* address of signal trampoline */
- int ps_refcnt; /* reference count */
+ sigset_t ps_sigmask; /* Current signal mask. */
+ sigset_t ps_sigignore; /* Signals being ignored. */
+ sigset_t ps_sigcatch; /* Signals being caught by user. */
};
/* signal flags */
XXX
--
Jaromir Dolecek <jdolecek@NetBSD.org> http://www.ics.muni.cz/~dolecek/
@@@@ Wanna a real operating system ? Go and get NetBSD, dammit! @@@@