📄 mk_sche.c
字号:
/*+MHDR*/
/*
# clearcase: CmicroPatchRel2.3.3
+------------------------------------------------------------------------------+
| Modulname : MK_SCHE.C |
| Author : S&P Media GmbH Germany |
+------------------------------------------------------------------------------+
| |
| Description : |
| |
| This module implements the functionality of the SDL- |
| scheduler of the Cmicro Kernel. |
| |
| Callers of the functions contained in this module should |
| provide the following requirements : |
| |
| Requirements : |
| ----------------------- |
| The imported variable is to be initialized correctly : |
| <Root-process-table> |
| extern XCONST XPDTBL xmk_ROM_ptr xPDTBL [MAX_SDL_PROCESS_TYPES+1]; |
| |
| Exported variables of the SDL-scheduler (this module) |
| (read only by SDL-Application) |
| ----------------------------------------------- |
| xmk_T_MESSAGE *xmk_SignalInstPtr Pointer to current SDL-signal |
| to work on |
| xPID xRunPID stores the value of SELF |
| #if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) |
| xPIDTable *pRunPIDTable stores SDL_PARENT,SDL_OFFSPRING |
| #endif |
| xINSTD *pRunData Pointer to <instance-data-struct> |
| of currently running process. |
| #ifdef XMK_USE_PREEMPTIVE |
| T_E_SIGNAL *PrioQueue[] Pointer to different prio-level queues |
| #endif |
| |
| #ifndef XMK_USE_PREEMPTIVE |
| xSYMBOLNR xmk_SymbolNrVar Global variable to select the appropriate |
| transition in the yPAD function ... |
| #endif |
| |
| |
| |
| M1 Errormessages, which are routed to the ErrorHandler |
| -------------------------------------------------------- |
| ERR_N_NO_COR_PRIO Errorcheck is conditionally compiled |
| If preemption is selected, this error |
| can come up, if the priority levels |
| are not set appropriately. |
| ERR_N_NO_CONT_PRIO Errorcheck is conditionally compiled |
| If preemption is selected, this error |
| can come up, if the priority levels |
| are not set appropriately. |
| ERR_N_xRouteSignal Errorcheck is conditionally compiled |
| If a signal has no defined receiver- |
| process. Note : This errorcheck is |
| used only when a signal route function |
| is defined by the user. |
| ERR_N_SDL_DISCARD Errorcheck is conditionally compiled |
| Error is detected, if a signal is sent |
| to a non existent process (a sleeping |
| one), or of the process is in a state, |
| where this signal neither can be |
| consumed not saved. |
| ERR_N_TRANS_TIME Errorcheck is conditionally compiled |
| Maximum timeout for the execution of |
| a transition exceeded. |
| ERR_N_CREATE_NO_MEM Errorcheck is conditionally compiled |
| It wasn't possible to allocate the |
| SDL-createsignal for process creation. |
| ERR_N_CREATE_INSTANCE Errorcheck is conditionally compiled |
| It wasn't possible to create a process |
| ERR_N_SYSTEM_SIGNAL Errorcheck is conditionally compiled |
| A Signal was treated as an systemsignal |
| but is not defined in the list of |
| systemsignals. |
| |
| M2 Exported functions of this module : |
| -------------------------------------------------------- |
l void *SI*StartProcesses (void) |
| void *SI*ProcessSignal (void) |
| xmk_T_INSTANCE *SI*CreateProcess (xmk_T_PROCESS) *1 |
| xmk_T_BOOL *SI*IsAnyProcessAlive (void) *1 |
| void xmk_InitPreemptionVars (void) *1 *2 |
| void xmk_DisablePreemption (void) *1 *2 |
| void xmk_EnablePreemption (void) *1 *2 |
| xmk_T_PRIOLEVEL xmk_FetchHighestPrioLevel (void) *1 *2 |
| void xmk_CheckIfSchedule (void) *1 *2 |
| void xmk_SwitchPrioLevel (xmk_T_PRIOLEVEL) *1 *2 |
| xmk_T_STATE *SI*GetProcessState (void) *1 *3 |
| xmk_T_BOOL *SI*KillProcess (xPID) *1 *3 |
| |
| The marker *SI* above means "SystemID". For each partitioned system there |
| is a unique name which is used as a prefix for making it possible to |
| compile/link several Cmicro Kernel plus system into one executable pro- |
| gram. The functions xmk_ above are not available in partitioned systems, |
| because these can be used to preemptive configuration of Cmicro Kernel |
| only. |
| |
| Those functions marked with *1 are compiled conditionally. Functions |
| marked with *2 are compiled only for a so scaled preemptive Cmicro Kernel.|
| Functions marked with *3 are compiled only for the Cmicro Tester. |
| |
| |
| M3 Static functions of this module : |
| -------------------------------------------------------- |
| .... *SI*HandleSystemSignal (...) |
| .... *SI*CheckSignal (...) |
| |
+------------------------------------------------------------------------------+
*/
/*-MHDR*/
/*
+------------------------------------------------------------------------------+
| |
| Copyright by Telelogic AB 1993 - 1998 |
| Copyright by S&P Media GmbH Germany 1993 - 1998 |
| |
| This Program is owned by Telelogic and is protected by national |
| copyright laws and international copyright treaties. Telelogic |
| grants you the right to use this Program on one computer or in |
| one local computer network at any one time. |
| Under this License you may only modify the source code for the purpose |
| of adapting it to your environment. You must reproduce and include |
| any copyright and trademark notices on all copies of the source code. |
| You may not use, copy, merge, modify or transfer the Program except as |
| provided in this License. |
| Telelogic does not warrant that the Program will meet your |
| requirements or that the operation of the Program will be |
| uninterrupted and error free. You are solely responsible that the |
| selection of the Program and the modification of the source code |
| will achieve your intended results and that the results are actually |
| obtained. |
| |
+------------------------------------------------------------------------------+
*/
/*
condat porting guide, implement now 2002/10/30
-----------------------------------------------------------------------------
The lines 323, 332, 400, 406, 545,550, 1562 and 1567 must be commented out in
order to avoid a system crash due to the undefined variable
static xmk_T_MESSAGE xmk_EmptySignalVar; This potential bug has been reported to AUS.
----------------------------------------------------------------------------
*/
#ifndef __MK_SCHE_C_
#define __MK_SCHE_C_
/*+IMPORT*/
/*==================== I M P O R T =========================================*/
#include "ml_typw.h"
#include "cmmnrsrc.h"
/*-------------------- Variables -----------------------------------------*/
#ifndef NO_GLOBAL_VARS
/* Modified by GBU,990518 */
extern XCONST XPDTBL xmk_ROM_ptr xPDTBL[MAX_SDL_PROCESS_TYPES+1]; /* <root-process-table> */
#endif
/*============================================================================*/
/*-IMPORT*/
/*+EXPORT*/
/*==================== E X P O R T =========================================*/
#ifndef NO_GLOBAL_VARS
xPID xRunPID; /* PID of currently active SDL-Process */
/* to retrieve SDL_SELF */
#if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING)
xPIDTable xmk_RAM_ptr pRunPIDTable; /* Pointer to PID-table of currently*/
/* running process; this is to */
/* enable access to SDL_OFFSPRING */
/* and SDL_PARENT. */
#endif /* ... defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) */
xINSTD xmk_RAM_ptr pRunData; /* Pointer to currently running */
/* processinstance - data */
xmk_T_MESSAGE xmk_RAM_ptr xmk_SignalInstPtr; /* Pointer to current SDL-signal */
/* to work on */
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
T_E_SIGNAL xmk_RAM_ptr Prio_Queue[MAX_PRIO_LEVELS];
/* Used to store the queue- */
/* pointers of the different */
/* priority-levels */
#endif
/*-PREEMPT*/
#ifndef XMK_USE_PREEMPTIVE
xSYMBOLNR xmk_SymbolNrVar ; /* Select appropriate Transition */ /* in yPAD function ... */
#endif
unsigned char xmk_InterruptsDisabled; /* To store whether the hardware */
/* interrupts are disabled or not*/
#if defined(XMK_ADD_MICRO_TESTER) && defined(XMK_ADD_CQUERY_PROCESS)
xmk_T_PRS_PROF xmk_ProcessProfiles [MAX_SDL_PROCESS_TYPES];
#endif
#endif /*NO_GLOBAL_VARS*/
/*
** Switch off any error check
*/
#ifdef XMK_USE_NO_ERR_CHECK
#define ErrorHandler(errnum)
#endif
/*============================================================================*/
/*-EXPORT*/
/*+MGG*/
/*==================== V A L U E S O F T H I S M O D U L E =============*/
/*-------------------- Constants, Macros ----------------------------------*/
#ifdef ANY_STATE
#undef ANY_STATE
#endif
#define ANY_STATE 0
/*
** Check Signal Results
*/
#ifdef SAVE_NOT_TRACE
#undef SAVE_NOT_TRACE
#endif
#define SAVE_NOT_TRACE -1
#ifdef SAVE
#undef SAVE
#endif
#define SAVE -2
#ifdef DISCARD
#undef DISCARD
#endif
#define DISCARD -3
#ifdef IMPLICIT_CONSUMPTION
#undef IMPLICIT_CONSUMPTION
#endif
#define IMPLICIT_CONSUMPTION -4
/*
** Internal Value(running proc-type)
*/
#ifdef RUN_PROC
#undef RUN_PROC
#endif
#define RUN_PROC EPIDTYPE(xRunPID)
/*
** Internal Value(running proc-inst)
*/
#ifdef RUN_INST
#undef RUN_INST
#endif
#define RUN_INST EPIDINST(xRunPID)
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
/*
** Internal value (priority-level of currently running process)
*/
#undef EPRIOLEVEL
#define EPRIOLEVEL xPDTBL[EPIDTYPE(xRunPID)]->PrioLevel
#endif
/*-PREEMPT*/
/*-------------------- Typedefinitions ----------------------------------*/
/*-------------------- Functions -----------------------------------------*/
/*static*/ int xmk_CheckSignal XPP (( xmk_T_SIGNAL, xmk_T_STATE, XCONST XPDTBL xmk_ROM_ptr));
#ifdef XMK_USED_DYNAMIC_CREATE
/*static*/ void xmk_HandleSystemSignal XPP (( xmk_T_MESSAGE xmk_RAM_ptr));
#endif
/*+PREEMPT*/
#ifdef XMK_USE_PREEMPTIVE
void xmk_CheckIfSchedule XPP (( void ));
#endif
/*-PREEMPT*/
/*-------------------- Variables ------------------------------------------*/
/*+PREEMPT*/
#ifndef NO_GLOBAL_VARS
#ifdef XMK_USE_PREEMPTIVE
static unsigned char xmk_PreemptionDisabled; /* Used to store */
/* whether preemption */
/* is disabled or not */
xmk_T_PRIOLEVEL CurrentPrioLevel, /* current prio-level */
HighestPrioLevel; /* highest prio-level */
/* where there is a */
/* signal */
T_E_SIGNAL xmk_RAM_ptr Prio_CurrentSignal[MAX_PRIO_LEVELS];
/* storing the signal */
/* currently worked on */
xPID Prio_xRunPID[MAX_PRIO_LEVELS];
/* storing current PID */
#if defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING)
xPIDTable xmk_ROM_ptr Prio_pRunPIDTable[MAX_PRIO_LEVELS];
/* Used to store the */
/* current processes */
/* PARENT & OFFSPRING */
/* information */
#endif /* ... defined(XMK_USED_PARENT) || defined(XMK_USED_OFFSPRING) */
xINSTD xmk_RAM_ptr Prio_pRunData[MAX_PRIO_LEVELS];
/* storing local data */
/* of current process */
#endif /* XMK_USE_PREEMPTIVE */
/*-PREEMPT*/
// #if defined(XMK_USED_SENDER) && defined(XMK_USE_MAX_ERR_CHECK) && defined(XMK_USE_SAFE_ADDRESSING)
/*
** Usually SDL_SENDER is evaluated with xmk_SignalInstPtr->send
** but this is not possible in start transition and when
** a processinstance is dynamically allocated because
** xmk_SignalInstPtr does not point to a valid signal.
** Therefore, a dummy message must be defined.
*/
static xmk_T_MESSAGE xmk_EmptySignalVar;
// #endif /* defined(XMK_USED_SENDER) && defined(XMK_USE_MAX_ERR_CHECK) && defined(XMK_USE_SAFE_ADDRESSING) */
#endif /* NO_GLOBAL_VARS */
/*============================================================================*/
/*-MGG*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -