00001
00010
00011
00012
00013
00014
00015 int _immediateReady = 0;
00016
00017 int _immRunning=0;
00018
00019
00020
00021
00022 #if CMK_IMMEDIATE_MSG
00023
00024
00025 static void *currentImmediateMsg=NULL;
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 extern "C" void CmiPushImmediateMsg(void *msg)
00036 {
00037 MACHSTATE(4,"pushing immediate message {");
00038
00039
00040
00041
00042 CmiLock(CsvAccess(NodeState).immSendLock);
00043 CMIQueuePush(CsvAccess(NodeState).immQ, (char *)msg);
00044 CmiUnlock(CsvAccess(NodeState).immSendLock);
00045 MACHSTATE(4,"} pushing immediate message");
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055 void CmiDelayImmediate(void)
00056 {
00057 MACHLOCK_ASSERT(_immRunning,"CmiDelayImmediate");
00058
00059 #if CMI_QD
00060 CQdCreate(CpvAccess(cQdState),1);
00061 #endif
00062 MACHSTATE(5,"Actually delaying an immediate message");
00063 CMIQueuePush(CsvAccess(NodeState).delayedImmQ, (char *)currentImmediateMsg);
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 void CmiHandleImmediateMessage(void *msg) {
00075
00076 int handlerNo=CmiImmediateHandler(msg);
00077 CmiHandlerInfo *h;
00078 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
00079 CmiAssert(0);
00080 #endif
00081 MACHSTATE2(4,"immediate message handler %d %d", CmiGetHandler(msg), handlerNo)
00082
00083 h = &CpvAccess(CmiHandlerTable)[handlerNo];
00084 CmiAssert(h && h->hdlr);
00085
00086 MACHLOCK_ASSERT(_immRunning,"CmiHandleImmediateMessage");
00087 #if CMI_QD
00088 CQdProcess(CpvAccess(cQdState),1);
00089 #endif
00090 (h->hdlr)(msg,h->userPtr);
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100 void CmiHandleImmediate(void)
00101 {
00102 void *msg;
00103
00104
00105 if (!_immediateReady) return;
00106
00107
00108 if (CmiTryLock(CsvAccess(NodeState).immRecvLock)!=0) return;
00109
00110
00111
00112
00113
00114 MACHLOCK_ASSERT(!_immRunning,"CmiHandleImmediate");
00115 _immRunning=1;
00116 MACHSTATE(2,"Entered handleImmediate {")
00117
00118
00119 while (NULL!=(msg=CMIQueuePop(CsvAccess(NodeState).immQ)))
00120 {
00121 currentImmediateMsg = msg;
00122 MACHSTATE(4,"calling immediate message handler {");
00123 CmiHandleImmediateMessage(msg);
00124 MACHSTATE(4,"} calling immediate message handler");
00125 }
00126
00127
00128 while (NULL!=(msg=CMIQueuePop(CsvAccess(NodeState).delayedImmQ)))
00129 CmiPushImmediateMsg(msg);
00130
00131 MACHSTATE(2,"} exiting handleImmediate")
00132 _immRunning = 0;
00133
00134 CmiUnlock(CsvAccess(NodeState).immRecvLock);
00135
00136 CmiClearImmediateFlag();
00137 }
00138
00139 #endif
00140