Interrupts, Shared Memory, and Critical Sections (Persistent)
Table of Contents
This section provides a high level overview of the interrupt enabling/disabling mechanisms in both the 68332 and host
environements and access to shared memory--both are part of the management of critical sections.
Part of the design of macro use was to avoid direct use of specific component macros (WCOS/uC/OS-II). Thus, if you change
one of these components, then the code using the OOMRM library would not have to be changed only the definition of the library macros.
Files
Three header files contain all the configuration for critical section management.
- model/shared.h : contains the storage mapping and macros for shared memory access (Persistent Storage).
- hardware/critical.h : contains macro definitions for controlling access to critical sections.
- host/wcos/hardware.h : contains macro defintions for accessing WCOS shared memory
Macros
The following are useful macros for critical section management:
NOTE: For accessing shared memory Ref. Persistent Storage.
- OS_ENTER_CRITICAL : (critical.h) This is the uC/OS-II macro; in 68332 environment it uses the OS_CRITICAL_METHOD
to determine how to
set the global interrupt status register (ORI #0x0700,%sr etc). On the host, this uses the
shared semaphore EnterCriticalSection(&WCCritSect) set up in WCOS.
This is set up in the call to WCInit(true) currently in m3.cpp. Thus, all initialization previous to this point
(mostly constructors) cannot use these macros in the host environement as the semaphore has not been set up yet.
- OOMRM_ENTER_CRITICAL : A "portability" macro currently assigned to OS_ENTER_MACRO. General, this one should be preferred
as it is designed to changed appropriately based upon current RTOS and environment used.
- HW_PEND_MEMORY : (host/wcos/wsim_core.h) WCOS macro for accessing shared memory. (WaitForSingleObject(HWMemoryMutex, INFINITE).
- OOMRM_PEND_MEMORY : (host/wcos/hardware.h) "portable" macro for accessing shared memory. on host, it translated to HW_PEND_MEMORY.
On 68332, it translated to OS_ENTER_CRITICAL if RTOS is defined (uC/OS); otherwise it is left NULL.