1 /* The kernel call implemented in this file:
4 * The parameters for this kernel call are:
5 * m1_i1: RC_ENDPT process number to control
6 * m1_i2: RC_ACTION stop or resume the process
7 * m1_i3: RC_FLAGS request flags
10 #include "../system.h"
14 /*===========================================================================*
16 *===========================================================================*/
17 PUBLIC
int do_runctl(struct proc
* caller
, message
* m_ptr
)
19 /* Control a process's RTS_PROC_STOP flag. Used for process management.
20 * If the process is queued sending a message or stopped for system call
21 * tracing, and the RC_DELAY request flag is given, set MF_SIG_DELAY instead
22 * of RTS_PROC_STOP, and send a SIGNDELAY signal later when the process is done
23 * sending (ending the delay). Used by PM for safe signal delivery.
25 int proc_nr
, action
, flags
, delayed
;
26 register struct proc
*rp
;
28 /* Extract the message parameters and do sanity checking. */
29 if (!isokendpt(m_ptr
->RC_ENDPT
, &proc_nr
)) return(EINVAL
);
30 if (iskerneln(proc_nr
)) return(EPERM
);
31 rp
= proc_addr(proc_nr
);
33 action
= m_ptr
->RC_ACTION
;
34 flags
= m_ptr
->RC_FLAGS
;
36 /* Is the target sending or syscall-traced? Then set MF_SIG_DELAY instead.
37 * Do this only when the RC_DELAY flag is set in the request flags field.
38 * The process will not become runnable before PM has called SYS_ENDKSIG.
39 * Note that asynchronous messages are not covered: a process using SENDA
40 * should not also install signal handlers *and* expect POSIX compliance.
42 if (action
== RC_STOP
&& (flags
& RC_DELAY
)) {
43 RTS_SET(rp
, RTS_SYS_LOCK
);
45 if (RTS_ISSET(rp
, RTS_SENDING
) || (rp
->p_misc_flags
& MF_SC_DEFER
))
46 rp
->p_misc_flags
|= MF_SIG_DELAY
;
48 delayed
= (rp
->p_misc_flags
& MF_SIG_DELAY
);
50 RTS_UNSET(rp
, RTS_SYS_LOCK
);
52 if (delayed
) return(EBUSY
);
55 /* Either set or clear the stop flag. */
58 RTS_SET(rp
, RTS_PROC_STOP
);
61 RTS_UNSET(rp
, RTS_PROC_STOP
);
70 #endif /* USE_RUNCTL */