📄 mk_sche.c
字号:
*/
InstanceID = xNULLINST ; /* == SDL_NULL */
/*
** Setting SDL_OFFSPRING in the creating Process ...
*/
#ifdef XMK_USED_OFFSPRING
/*
** Kernel already knows the parent; parent can be
** evaluated by using the xRunPID information, which
** stores the PID of the currently active process instance.
*/
pCurrentProcessPIDTable = xPDTBL [ RUN_PROC ]->pPIDTable;
pCurrentProcessPIDTable [RUN_INST].Offspring = xNULLPID;
#endif
} /* END IF */
else
{
XMK_BEGIN_CRITICAL_PATH;
/*
** if allocation succeeded, set the state of
** the instance to XCREATION
*/
pProcessType->ProcessStateTable [ InstanceID ] = XCREATION;
/*
* Dynamic instance data:
* A new process instance is being created, so we need to
* allocate space for its data.
*/
#ifndef XMK_USED_ONLY_X_1
((unsigned char **)(pProcessType->pInstanceData))[InstanceID] =
OSConnectorAlloc (pProcessType->DataLength);
memset (((unsigned char **)(pProcessType->pInstanceData))[InstanceID],
0, pProcessType->DataLength);
#else
pProcessType->pInstanceData =
OSConnectorAlloc (pProcessType->DataLength);
memset (pProcessType->pInstanceData, 0, pProcessType->DataLength);
#endif
XMK_END_CRITICAL_PATH;
/*
** register parameters
*/
p_CreMsg->rec = GLOBALPID(ProcessTypeID,InstanceID) ;
p_CreMsg->signal = XMK_CREATE_SIGNALID ;
#ifdef XMK_USE_SIGNAL_PRIORITIES
p_CreMsg->prio = XMK_CREATE_PRIO ;
#endif
/*
** Sender is currently active instance
*/
#ifdef XMK_USE_SENDER_PID_IN_SIGNAL
p_CreMsg->send = xRunPID ;
#endif
#ifdef XMK_USED_SIGNAL_WITH_PARAMS
p_CreMsg->mess_length = 0 ;
#endif
#ifdef XMK_ADD_TCREATE
xmk_TSDL_Create (p_CreMsg);
#endif
/*
** Setting SDL_OFFSPRING in the creating Process ...
*/
#ifdef XMK_USED_OFFSPRING
/*
** Kernel already knows the parent; parent can be
** evaluated by using the xRunPID information, which
** stores the PID of the currently active process instance.
*/
pCurrentProcessPIDTable = xPDTBL [ RUN_PROC ]->pPIDTable;
pCurrentProcessPIDTable [RUN_INST].Offspring = GLOBALPID(ProcessTypeID,InstanceID) ;
#endif
/*
** insert signal into queue
*/
xmk_InsertSignal ( p_CreMsg ) ;
} /* END ELSE */
} /* END IF */
else
{
/*
** if no instance found XDORMANT
** prepare return-value to indicate that creation failed
*/
InstanceID = xNULLINST ; /* == SDL_NULL */
/*
** and call error-handling routine
*/
ErrorHandler (ERR_N_CREATE_INSTANCE);
/*
** Setting SDL_OFFSPRING in the creating Process ...
*/
#ifdef XMK_USED_OFFSPRING
/*
** Kernel already knows the parent; parent can be
** evaluated by using the xRunPID information, which
** stores the PID of the currently active process instance.
*/
pCurrentProcessPIDTable = xPDTBL [ RUN_PROC ]->pPIDTable;
pCurrentProcessPIDTable [RUN_INST].Offspring = xNULLPID;
#endif
} /* END ELSE */
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_TRACE_EXIT("*SI*CreateProcess");
#endif
/*
** return ID of the created instance respectively error notification
*/
return( InstanceID ) ;
} /* END OF FUNCTION */
#endif /* XMK_USED_DYNAMIC_CREATE */
#ifdef XMK_USED_DYNAMIC_CREATE
/*+FHDR S*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_HandleSystemSignal |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| |
| This function handles systems signals. At the moment, there is only |
| one systemsignal defined. |
| Create-Signal: The <start-transition> of the <process-instance> to be |
| created will be executed. SDL_PARENT has to be stored in the PID-table of |
| the created process-instance. |
| |
| Parameter : p_Message - Pointer to systemsignal |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR S*/
/*+FDEF S*/
#ifndef XNOPROTO
/*static*/ void xmk_HandleSystemSignal ( xmk_T_MESSAGE xmk_RAM_ptr p_Message )
#else
static void xmk_HandleSystemSignal ( p_Message )
xmk_T_MESSAGE xmk_RAM_ptr p_Message;
#endif
/*-FDEF S*/
{
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_FUNCTION("*SI*HandleSystemSignal");
#endif
/*
** examine signal's code
*/
switch( p_Message->signal )
{
#ifdef XMK_USED_DYNAMIC_CREATE
/*
** if signal is create-signal
*/
case XMK_CREATE_SIGNALID:
{
XCONST XPDTBL xmk_ROM_ptr p_ReceiverProcess ;
xmk_T_TRANS_ADDRESS TransitionFunction ;
// #if defined(XMK_USED_SENDER) && defined(XMK_USE_MAX_ERR_CHECK) && defined(XMK_USE_SAFE_ADDRESSING)
/*
** For evaluation of SDL_SENDER expression :
*/
xmk_SignalInstPtr= &xmk_EmptySignalVar;
// #endif
/*
** load pointer with process-description-table of current processtype
*/
p_ReceiverProcess = xPDTBL [ RUN_PROC ] ;
/*
** if the state of the instance is XCREATION
*/
if( p_ReceiverProcess->ProcessStateTable [ RUN_INST ] == XCREATION )
{
XMK_BEGIN_CRITICAL_PATH;
/*
** load instance-data
*/
/*
* Dynamic instance data:
* The instance data was allocated already when this process
* was set up for creation, so here we just need to set
* the pRunData pointer.
*/
#ifndef XMK_USED_ONLY_X_1
pRunData = ((unsigned char **)(p_ReceiverProcess->pInstanceData))[RUN_INST];
#else
pRunData = p_ReceiverProcess->pInstanceData;
#endif
#if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING)
/*
** Evaluate pointer to table with parent/offspring value
*/
pRunPIDTable = &xPDTBL[ RUN_PROC ]->pPIDTable [RUN_INST];
/*
** Setting SDL_PARENT and SDL_OFFSPRING
*/
#ifdef XMK_USED_PARENT
pRunPIDTable->Parent = p_Message->send;
#endif
#ifdef XMK_USED_OFFSPRING
pRunPIDTable->Offspring = xNULLPID;
#endif
#endif /* ... defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) */
XMK_END_CRITICAL_PATH;
#ifdef XMK_USE_KERNEL_INIT
memset (pRunData, 0, p_ReceiverProcess->DataLength);
#endif
/*
** load transitionfunction
*/
TransitionFunction = xPDTBL [ RUN_PROC ]->yPAD_Function ;
#ifdef XMK_ADD_TDYNAMIC_CREATE
xmk_TSDL_DynamicCreate (p_Message->send, xRunPID);
#endif
#ifdef XMK_USE_BANKSW
XMK_SWITCH_BANK(EPIDTYPE(xRunPID));
#endif
/*
** execute transitionfunction and store nextstate
*/
#ifdef XMK_USE_PREEMPTIVE
p_ReceiverProcess->ProcessStateTable [ RUN_INST ] =
TransitionFunction(XSTART_TRANSITION) ;
#else
xmk_SymbolNrVar = 0;
p_ReceiverProcess->ProcessStateTable [ RUN_INST ] =
TransitionFunction() ;
#endif
#ifdef XMK_ADD_TSTATE
/*
** Trace the next state operation ...
*/
xmk_TSDL_State (p_ReceiverProcess->ProcessStateTable [ RUN_INST ]);
#endif
} /* END IF */
else
{
/*
** The state of the instance differs from XCREATION
** call error handling routine
*/
ErrorHandler (ERR_N_CREATE_INSTANCE);
} /* END ELSE */
/*
** remove create-signal from the queue
*/
xmk_RemoveCurrentSignal ();
#if defined(XMK_USE_DEBUGGING) || defined(XMK_USE_MICRO_COMMAND)
/*
** Set xRunPID no longer active, relevant only for
** debug, trace and command interface
*/
xRunPID = xNULLPID;
#ifdef XMK_USE_PREEMPTIVE
CurrentPrioLevel = MAX_PRIO_LEVELS;
#endif
#endif
break ;
} /* END CASE */
#endif /* XMK_USED_DYNAMIC_CREATE */
default :
#ifdef XMK_USE_NO_ERR_CHECK
/*
** really NO error check in this case
*/
#else
/*
** signal wasn't a create-signal
*/
ErrorHandler (ERR_N_SYSTEM_SIGNAL);
/*
** remove create-signal from queue
*/
xmk_RemoveCurrentSignal () ;
#endif
break ;
} /* END SWITCH */
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_TRACE_EXIT("*SI*HandleSystemSignal");
#endif
} /* END OF FUNCTION */
#endif /* XMK_USED_DYNAMIC_CREATE */
/*+FHDR S*/
/*
+------------------------------------------------------------------------------+
| Functionname : xmk_CheckSignal |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
|
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -