From: Tomas Hruby Date: Mon, 31 Oct 2011 15:21:08 +0000 (+0000) Subject: KERNEL - has_pending() not exposed X-Git-Tag: v3.2.0~137 X-Git-Url: http://zhaoyanbai.com/repos/?a=commitdiff_plain;h=e4d46a2146b9fe2842be85853031d269350c38d6;p=minix.git KERNEL - has_pending() not exposed - has_pending() takes a special argument that tells the code whether we are scanning for asynchronous message or something else. - has_pending() is not used directly anymore - the new functions are wrappings around has_pending() to make the use more comfortable. - these functions should become static inline eventually --- diff --git a/kernel/proc.c b/kernel/proc.c index 84d58235b..c46edc3f2 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -702,7 +702,7 @@ endpoint_t src_dst_e; /* src or dst process */ /*===========================================================================* * has_pending * *===========================================================================*/ -PUBLIC int has_pending(sys_map_t *map, int src_p) +PRIVATE int has_pending(sys_map_t *map, int src_p, int asynm) { /* Check to see if there is a pending message from the desired source * available. @@ -734,6 +734,33 @@ PUBLIC int has_pending(sys_map_t *map, int src_p) return(id); } +/*===========================================================================* + * has_pending_notify * + *===========================================================================*/ +PUBLIC int has_pending_notify(struct proc * caller, int src_p) +{ + sys_map_t * map = &priv(caller)->s_notify_pending; + return has_pending(map, src_p, 0); +} + +/*===========================================================================* + * has_pending_asend * + *===========================================================================*/ +PUBLIC int has_pending_asend(struct proc * caller, int src_p) +{ + sys_map_t * map = &priv(caller)->s_asyn_pending; + return has_pending(map, src_p, 1); +} + +/*===========================================================================* + * unset_notify_pending * + *===========================================================================*/ +PUBLIC void unset_notify_pending(struct proc * caller, int src_p) +{ + sys_map_t * map = &priv(caller)->s_notify_pending; + unset_sys_bit(*map, src_p); +} + /*===========================================================================* * mini_send * *===========================================================================*/ @@ -844,7 +871,6 @@ PRIVATE int mini_receive(struct proc * caller_ptr, * is available block the caller. */ register struct proc **xpp; - sys_map_t *map; int r, src_id, src_proc_nr, src_p; assert(!(caller_ptr->p_misc_flags & MF_DELIVERMSG)); @@ -871,10 +897,9 @@ PRIVATE int mini_receive(struct proc * caller_ptr, /* Check if there are pending notifications, except for SENDREC. */ if (! (caller_ptr->p_misc_flags & MF_REPLY_PEND)) { - map = &priv(caller_ptr)->s_notify_pending; /* Check for pending notifications */ - if ((src_id = has_pending(map, src_p)) != NULL_PRIV_ID) { + if ((src_id = has_pending_notify(caller_ptr, src_p)) != NULL_PRIV_ID) { endpoint_t hisep; src_proc_nr = id_to_nr(src_id); /* get source proc */ @@ -883,7 +908,7 @@ PRIVATE int mini_receive(struct proc * caller_ptr, printf("mini_receive: sending notify from NONE\n"); } #endif - unset_sys_bit(*map, src_id); /* no longer pending */ + unset_notify_pending(caller_ptr, src_id); /* no longer pending */ /* Found a suitable source, deliver the notification message. */ hisep = proc_addr(src_proc_nr)->p_endpoint; @@ -902,9 +927,7 @@ PRIVATE int mini_receive(struct proc * caller_ptr, } /* Check for pending asynchronous messages */ - map = &priv(caller_ptr)->s_asyn_pending; - - if (has_pending(map, src_p) != NULL_PRIV_ID) { + if (has_pending_asend(caller_ptr, src_p) != NULL_PRIV_ID) { if (src_p != ANY) r = try_one(proc_addr(src_p), caller_ptr); else diff --git a/kernel/proto.h b/kernel/proto.h index 3aae90a34..023d366a2 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -47,8 +47,10 @@ _PROTOTYPE( void bsp_finish_booting, (void) ); _PROTOTYPE( int do_ipc, (reg_t r1, reg_t r2, reg_t r3) ); _PROTOTYPE( void proc_init, (void) ); -_PROTOTYPE( int has_pending, (sys_map_t *map, int src_p) ); _PROTOTYPE( int cancel_async, (struct proc *src, struct proc *dst) ); +_PROTOTYPE( int has_pending_notify, (struct proc * caller, int src_p) ); +_PROTOTYPE( int has_pending_asend, (struct proc * caller, int src_p) ); +_PROTOTYPE( void unset_notify_pending, (struct proc * caller, int src_p)); _PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) ); _PROTOTYPE( void enqueue, (struct proc *rp) ); _PROTOTYPE( void dequeue, (struct proc *rp) ); diff --git a/kernel/system.c b/kernel/system.c index e74baa1f6..9007b4ce4 100644 --- a/kernel/system.c +++ b/kernel/system.c @@ -554,12 +554,10 @@ int caller_ret; /* code to return on callers */ /* Clear IPC references for a given process slot. */ struct proc *rp; /* iterate over process table */ int src_id; - sys_map_t *map; /* Tell processes that sent asynchronous messages to 'rc' they are not * going to be delivered */ - map = &priv(rc)->s_asyn_pending; - while ((src_id = has_pending(map, ANY)) != NULL_PRIV_ID) + while ((src_id = has_pending_asend(rc, ANY)) != NULL_PRIV_ID) cancel_async(proc_addr(id_to_nr(src_id)), rc); for (rp = BEG_PROC_ADDR; rp < END_PROC_ADDR; rp++) {