📄 mk_sche.c
字号:
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : *SI*StartProcesses |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| |
| This function implements the STARTUP-Phase of the SDL-System. All static |
| process-instances are created. |
| This means executing the start-transition of all process-instances to |
| be created. For each created process-instance, the first state is set. |
| If configured right, the values SDL_SELF, SDL_PARENT and SDL_OFFSPRING |
| are correctly initialized (only necessary if no semantic check was |
| performed, i.e.if someone doesn't use the SDT-Analyzer). |
| |
| Parameter : - |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
void xmk_StartProcesses ( void )
#else
void xmk_StartProcesses ( )
#endif
/*-FDEF E*/
{
unsigned char Process ;
#ifndef XMK_USED_ONLY_X_1
/*
** Loop over instances of a type only if more than 1 instance ...
*/
unsigned char Instance ;
#endif
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
unsigned char priority;
#ifdef XMK_USE_MAX_ERR_CHECK
unsigned char PrioLevelNumbering;
#endif
#endif
/*-PREEMPT*/
XCONST XPDTBL xmk_ROM_ptr pProcessType ;
xmk_T_TRANS_ADDRESS TransitionFunction ;
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_FUNCTION("*SI*StartProcesses");
#endif
PRINTF(("vorwhile_1 "));
//#if defined(XMK_USED_SENDER) && defined(XMK_USE_MAX_ERR_CHECK) && defined(XMK_USE_SAFE_ADDRESSING)
/*
** For evaluation of SDL_SENDER expression :
*/
xmk_EmptySignalVar.send = xNULLPID;
PRINTF(("vorwhile_2 "));
//#endif
#ifdef XMK_USED_INITFUNC
/*
** Initialization used only for synonyms, which cannot
** become an C define, but must be an variable ...
*/
PRINTF(("vorwhile_3 "));
yInit ();
#endif
#ifndef XMK_USE_PREEMPTIVE
xmk_SymbolNrVar = 0;
#endif
#ifndef XMK_USE_PREEMPTIVE
#ifdef XMK_ADD_CQUERY_PROCESS
memset ((void*) &xmk_ProcessProfiles, 0, sizeof (xmk_ProcessProfiles));
#endif
#endif
#ifdef XMK_USE_PREEMPTIVE
#ifdef XMK_USE_MAX_ERR_CHECK
priority = 0;
for (Process = 0; Process < MAX_SDL_PROCESS_TYPES; Process++)
{
if (xPDTBL[Process]->PrioLevel > priority)
priority = xPDTBL[Process]->PrioLevel;
}
priority++;
if (priority != MAX_PRIO_LEVELS)
{
ErrorHandler(ERR_N_NO_COR_PRIO);
}
PrioLevelNumbering = 0;
for (priority = 0; priority < MAX_PRIO_LEVELS; priority ++)
{
Process = 0;
while ( xPDTBL [Process] != X_END_ROOT_TABLE )
{
if ( xPDTBL[Process]->PrioLevel == priority )
{
PrioLevelNumbering++;
Process++;
break;
}
Process++;
}
}
if (PrioLevelNumbering != MAX_PRIO_LEVELS)
{
ErrorHandler(ERR_N_NO_CONT_PRIO);
}
#endif
/*
** search for the processtype with the highest priority
** to create all the instances of this type the SDL-system
** defined as to be created at system startup and go on
** with decreasing priorities
*/
for (priority = 0; priority < MAX_PRIO_LEVELS; priority ++)
{
for (Process = 0;
((pProcessType = xPDTBL[Process]) != X_END_ROOT_TABLE);
Process ++)
{
if (xPDTBL[Process]->PrioLevel == priority)
{
#else
Process = 0;
/*
** Loop in <root-process-table>
*/
while ( (pProcessType = xPDTBL [Process]) != X_END_ROOT_TABLE )
{
#endif
PRINTF(("while "));
TransitionFunction = pProcessType->yPAD_Function;
#ifndef XMK_USED_ONLY_X_1
Instance = 0 ;
/*
** Loop in <process-state-table> for all instances of this processtype
*/
while ((Instance < pProcessType->MaxInstances) &&
(pProcessType->ProcessStateTable[Instance] == XSTARTUP)
)
#else
if ( pProcessType->ProcessStateTable[0] == XSTARTUP )
#endif
{
#ifdef XMK_ADD_PRINTF_ADDITIONAL
xxmonPID ("Starting Process :", GLOBALPID(Process,Instance));
#endif /* ... XMK_ADD_PRINTF_ADDITIONAL */
/*
** load global variable with current instances identification
*/
xRunPID = GLOBALPID(Process,Instance);
/*
** Load pointer to instancedata to enable access in start-transition
*/
/*
* Dynamic instance data:
* Here we allocate memory for the data for
* those process instances that exist on startup.
*/
#ifndef XMK_USED_ONLY_X_1
((unsigned char **)(pProcessType->pInstanceData))[RUN_INST] =
OSConnectorAlloc (pProcessType->DataLength);
pRunData = ((unsigned char **)(pProcessType->pInstanceData))[RUN_INST];
memset (pRunData, 0, pProcessType->DataLength);
#else
pProcessType->pInstanceData =
OSConnectorAlloc (pProcessType->DataLength);
pRunData = pProcessType->pInstanceData;
memset (pRunData, 0, pProcessType->DataLength);
#endif
/*
** Setting SDL_PARENT, SDL_OFFSPRING and SDL_SENDER to NULL ...
*/
#if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING)
pRunPIDTable = &( pProcessType->pPIDTable [RUN_INST]) ;
#ifdef XMK_USED_PARENT
pRunPIDTable->Parent = xNULLPID;
#endif
#ifdef XMK_USED_OFFSPRING
pRunPIDTable->Offspring = xNULLPID;
#endif
#endif /* ... defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) */
// #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
#ifdef XMK_USE_KERNEL_INIT
memset (pRunData, 0, pProcessType->DataLength);
#endif
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
XMK_QUEUE_ADR = &(Prio_Queue[priority]);
XMK_CURRENTSIGNAL_ADR = &(Prio_CurrentSignal[priority]);
#ifdef XMK_ADD_TSYS_SHOWPRIO
/*
** Show Prio Level on MSC if wanted ...
*/
xmk_tsys_ShowPrioLevel (priority);
#endif /* ... XMK_ADD_TSYS_SHOWPRIO */
#endif /* ... XMK_USE_PREEMPTIVE */
/*-PREEMPT*/
#ifdef XMK_ADD_TSTATIC_CREATE
/*
** All other Traces ...
*/
xmk_TSDL_StaticCreate (xRunPID);
#endif
#ifdef XMK_ADD_PRINTF_ADDITIONAL
xxmonPID ("Starttransition of :", GLOBALPID(Process,Instance));
#endif /* ... XMK_ADD_PRINTF_ADDITIONAL */
#ifdef XMK_USE_BANKSW
XMK_SWITCH_BANK(EPIDTYPE(xRunPID));
#endif
/*
** Call the start-transition ...
*/
#ifdef XMK_USE_PREEMPTIVE
pProcessType->ProcessStateTable[ RUN_INST ] = TransitionFunction (XSTART_TRANSITION);
#else
/*
** xmk_SymbolNrVar set appropriate in function entry ...
*/
pProcessType->ProcessStateTable[ RUN_INST ] = TransitionFunction ();
#endif
#ifdef XMK_ADD_TSTATE
xmk_TSDL_State ( pProcessType->ProcessStateTable[ RUN_INST ] );
#endif
/*
** Set xRunPID no longer active, relevant only for
** debug, trace and command interface.
** It is not necessary to update the current prio-level,
** because preemption is disabled during system startup phase.
*/
xRunPID = xNULLPID;
#ifndef XMK_USED_ONLY_X_1
Instance++ ;
#endif
} /* testing if processinstances are to be statically created */
#ifdef XMK_USE_PREEMPTIVE
} /* if xPDTBL...*/
} /* for Process = ... */
} /* for priority = ... */
/*
** necessary to prevent from scheduling before actually starting
** the SDL-system itself
*/
CurrentPrioLevel = 0;
#else
Process++ ;
} /* END WHILE (testing processtypes) */
#endif
#ifdef XMK_ADD_PRINTF_SCHEDULER
XMK_TRACE_EXIT ("*SI*StartProcesses");
#endif
} /* END OF FUNCTION */
/*+FHDR E*/
/*
+------------------------------------------------------------------------------+
| Functionname : *SI*ProcessSignal |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| |
| This function processes an SDL-signal and remains in an internal loop, |
| until a signal was processed, or until no signal is remaining in any |
| input-port in the SDL-system. |
| |
| Parameter : - |
| |
| Return : - |
| |
+------------------------------------------------------------------------------+
*/
/*-FHDR E*/
/*+FDEF E*/
#ifndef XNOPROTO
void xmk_ProcessSignal ( void )
#else
void xmk_ProcessSignal ( )
#endif
/*-FDEF E*/
{
XCONST XPDTBL xmk_ROM_ptr p_ReceiverProcess ;
xmk_T_MESSAGE xmk_RAM_ptr p_Message ;
xmk_T_TRANS_ADDRESS TransitionFunction ;
xmk_T_STATE State ;
#define CurrentState State
#define NextState State
#ifdef XMK_USE_PREEMPTIVE
xSYMBOLNR TmpSymbolNr ;
#endif
#if defined(XMK_ADD_MICRO_TESTER) && defined(XMK_ADD_PSC_TRACE)
xmk_T_CMD_TPSC_TRACE PSCTrace;
xmk_T_CMD_TPSC_TIME PSCTime;
#endif
int TestResult ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -