From 9192dbecc932ac9b87e954b9adcf177aeb8e8739 Mon Sep 17 00:00:00 2001 From: Cristiano Giuffrida Date: Sat, 27 Mar 2010 00:09:22 +0000 Subject: [PATCH] Preserve the order of IPC messages between two parties. Currently a sequence of messages between a sender A and a receiver B of the form: A.asynsend(M1, B); A.send(M2, B) may result in the receiver receiving M1 first and then M2 or viceversa. This patch makes sure that the original order M1, M2 is always preserved. Note that the order of a hypotetical sequence A.asynsend(M1, B); A.asynsend(M2, B) is already guaranteed by the implementation of asynsend by design. Other senda-based wrappers can define their own semantics. --- kernel/proc.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/proc.c b/kernel/proc.c index 193b6862d..7062c5899 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -684,6 +684,20 @@ int flags; } } + /* Check if there are pending senda(). */ + if (caller_ptr->p_misc_flags & MF_ASYNMSG) + { + if (src_e != ANY) + r= try_one(proc_addr(src_p), caller_ptr, NULL); + else + r= try_async(caller_ptr); + + if (r == OK) { + IPC_STATUS_ADD(caller_ptr, IPC_STATUS_CALL_TO(SENDA)); + return OK; /* Got a message */ + } + } + /* Check caller queue. Use pointer pointers to keep code simple. */ xpp = &caller_ptr->p_caller_q; while (*xpp != NIL_PROC) { @@ -706,19 +720,6 @@ int flags; } xpp = &(*xpp)->p_q_link; /* proceed to next */ } - - if (caller_ptr->p_misc_flags & MF_ASYNMSG) - { - if (src_e != ANY) - r= try_one(proc_addr(src_p), caller_ptr, NULL); - else - r= try_async(caller_ptr); - - if (r == OK) { - IPC_STATUS_ADD(caller_ptr, IPC_STATUS_CALL_TO(SENDA)); - return OK; /* Got a message */ - } - } } /* No suitable message is available or the caller couldn't send in SENDREC.