Exercises related to Robust Design Patterns - Part 3
MPU Protection
How to handle an exception
Exercice 1
We have seen during the lecture that an exception is raised in case a memory violation occures. Checking the manual contained in the repository:
- can you state what function it is? What does its default implementation?
- can you infer what thread triggered the violation?
- what other pieces of information may one get?
Understanding memory partitioning and zoning
Exercice 2
Look at the following zone to ressource allocation:
- Assume the idle task, belonging to Zone_Idle, is run in unpriviledged
mode. Is there any issue with the above assignments? Could there be any
issue as it can access - at least from the table above - to sensitive
areas like
ARM_LIB_STACK
? (note:ARM_LIB_STACK
is reserved for the ARM C library stack) - Take the above ressource allocation and the line of code
What does this line do with regard to where
static uint32_t sensor_val __attribute__((section("ram_shared"))) = 0U;
sensor_val
is put in memory?
Exercice 3
Look at the following code defining threads attributes:
static uint64_t stack_thrTire[64]; // Stack of Tire Thread
static osThreadId_t tid_thrTire; // Thread id of Tire Thread
const static osThreadAttr_t attr_thrTire = { // Thread attributes of Tire Thread
.name = "TireThread",
#ifdef SOME_MAGIC
.attr_bits = osThreadUnprivileged | osThreadZone(ZONE_NORMAL_OP) | osSafetyClass(SAFETY_CLASS_NORMAL),
#else
.attr_bits = osThreadUnprivileged,
#endif
.cb_mem = NULL,
.cb_size = 0,
.stack_mem = &stack_thrTire,
.stack_size = sizeof(stack_thrTire),
.priority = 11,
.tz_module = 0,
.reserved = 0};
- What does
SOME_MAGIC
do in your opinion? - Do you see any major differences compared to the way attributes for instantiating tasks have been defined so far?
Safety Class
Activating the functionality
Exercice 4
If you access
RTX_Config.h
you will see that OS_SAFETY_CLASS
exists. Please answer following questions:
- is it sufficient to activate
OS_SAFETY_CLASS
to get the functionality? - if not, what else should one activate?
- what is one cannot do when this is activated?
- how many files are modified when this flag is activated?
Understanding its way of working
Exercice 5
These are just exemplary questions related to a functionality you are now
familiar with: semaphores. The questions related to the code present in the
development branch
(thus, version > 5.9.1
)
- what is the check concerning SAFETY_CLASS done when acquiring a semaphore?
- what does a call to
svcRtxSemaphoreDelete
do when destroying a semaphore?