Deleted Added
full compact
kern_kthread.c (52140) kern_kthread.c (55539)
1/*
2 * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 1999 Peter Wemm <peter@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_kthread.c 52140 1999-10-11 20:33:17Z luoqi $
26 * $FreeBSD: head/sys/kern/kern_kthread.c 55539 2000-01-07 08:36:44Z luoqi $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/proc.h>
32#include <sys/kthread.h>
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/proc.h>
32#include <sys/kthread.h>
33#include <sys/signalvar.h>
33#include <sys/unistd.h>
34#include <sys/wait.h>
35
36#include <machine/stdarg.h>
37
38/*
39 * Start a kernel process. This is called after a fork() call in
40 * mi_startup() in the file kern/init_main.c.

--- 51 unchanged lines hidden (view full) ---

92}
93
94void
95kthread_exit(int ecode)
96{
97 exit1(curproc, W_EXITCODE(ecode, 0));
98}
99
34#include <sys/unistd.h>
35#include <sys/wait.h>
36
37#include <machine/stdarg.h>
38
39/*
40 * Start a kernel process. This is called after a fork() call in
41 * mi_startup() in the file kern/init_main.c.

--- 51 unchanged lines hidden (view full) ---

93}
94
95void
96kthread_exit(int ecode)
97{
98 exit1(curproc, W_EXITCODE(ecode, 0));
99}
100
101/*
102 * Advise a kernel process to suspend (or resume) in its main loop.
103 * Participation is voluntary.
104 */
105int
106suspend_kproc(struct proc *p, int timo)
107{
108 /*
109 * Make sure this is indeed a system process and we can safely
110 * use the p_siglist field.
111 */
112 if ((p->p_flag & P_SYSTEM) == 0)
113 return (EINVAL);
114 SIGADDSET(p->p_siglist, SIGSTOP);
115 return tsleep((caddr_t)&p->p_siglist, PPAUSE, "suspkp", timo);
116}
117
118int
119resume_kproc(struct proc *p)
120{
121 /*
122 * Make sure this is indeed a system process and we can safely
123 * use the p_siglist field.
124 */
125 if ((p->p_flag & P_SYSTEM) == 0)
126 return (EINVAL);
127 SIGDELSET(p->p_siglist, SIGSTOP);
128 wakeup((caddr_t)&p->p_siglist);
129 return (0);
130}
131
132void
133kproc_suspend_loop(struct proc *p)
134{
135 while (SIGISMEMBER(p->p_siglist, SIGSTOP)) {
136 wakeup((caddr_t)&p->p_siglist);
137 tsleep((caddr_t)&p->p_siglist, PPAUSE, "kpsusp", 0);
138 }
139}