New P_BLOCKEDON for kernel - a macro that encodes the "who is this
process waiting for" logic, which is duplicated a few times in the
kernel. (For a new feature for top.)
Introducing it and throwing out ESRCDIED and EDSTDIED (replaced by
EDEADSRCDST - so we don't have to care which part of the blocking is
failing in system.c) simplifies some code in the kernel and callers that
check for E{DEADSRCDST,ESRCDIED,EDSTDIED}, but don't care about the
difference, a fair bit, and more significantly doesn't duplicate the
'blocked-on' logic.
This commit is contained in:
@@ -157,6 +157,25 @@ struct proc {
|
||||
#define proc_is_preempted(p) ((p)->p_rts_flags & RTS_PREEMPTED)
|
||||
#define proc_no_quantum(p) ((p)->p_rts_flags & RTS_NO_QUANTUM)
|
||||
|
||||
/* Macro to return: on which process is a certain process blocked?
|
||||
* return endpoint number (can be ANY) or NONE. It's important to
|
||||
* check RTS_SENDING first, and then RTS_RECEIVING, as they could
|
||||
* both be on (if a sendrec() blocks on sending), and p_getfrom_e
|
||||
* could be nonsense even though RTS_RECEIVING is on.
|
||||
*/
|
||||
#define P_BLOCKEDON(p) \
|
||||
( \
|
||||
((p)->p_rts_flags & RTS_SENDING) ? \
|
||||
(p)->p_sendto_e : \
|
||||
( \
|
||||
( \
|
||||
((p)->p_rts_flags & RTS_RECEIVING) ? \
|
||||
(p)->p_getfrom_e : \
|
||||
NONE \
|
||||
) \
|
||||
) \
|
||||
)
|
||||
|
||||
/* These runtime flags can be tested and manipulated by these macros. */
|
||||
|
||||
#define RTS_ISSET(rp, f) (((rp)->p_rts_flags & (f)) == (f))
|
||||
|
||||
Reference in New Issue
Block a user