@@ -28,41 +28,55 @@ extern "C" {
28
28
*/
29
29
30
30
/**
31
- * Mark the start of a critical section
32
- *
33
- * This function is called directly by core_util_critical_section_enter on
34
- * first entrance to a critical section.
35
- *
36
- * There is a default implementation of this function which will save the
37
- * current state of interrupts before disabling them. This implementation can
38
- * be found in mbed_critical_section_api.c. This behaviour is can be overridden
39
- * on a per platform basis by providing a different implementation within the
40
- * correct targets directory.
41
- *
42
- * The function is only called once per critical section by
43
- * core_util_critical_section_enter. When implementing this function for a
44
- * platform you must store any state that you intend to alter within this
45
- * function so it can be restored when exiting the critical section.
46
- *
47
- */
31
+ * Mark the start of a critical section
32
+ *
33
+ * This function will be called by core_util_critical_section_enter() each time
34
+ * the application requests to enter a critical section. The purpose of the
35
+ * critical section is to ensure mutual-exclusion synchronisation of the
36
+ * processor by preventing any change in processor control, the default
37
+ * behaviour requires storing the state of interrupts in the system before
38
+ * disabling them.
39
+ *
40
+ * The critical section code supports nesting. When a thread has entered a
41
+ * critical section it can make additional calls to
42
+ * core_util_critical_section_enter() without deadlocking itself. The critical
43
+ * section driver API tracks the number of nested calls to the critical section.
44
+ * The critical section will only be exited when
45
+ * core_util_critical_section_exit() has been called once for each time it
46
+ * entered the critical section.
47
+ *
48
+ * On the first call to enter a critical section this function MUST store the
49
+ * state of any interrupts or other application settings it will modify to
50
+ * facilitate the critical section.
51
+ *
52
+ * Each successive call to enter the critical section MUST ignore storing or
53
+ * modifying any application state.
54
+ *
55
+ * The default implementation of this function which will save the current state
56
+ * of interrupts before disabling them. This implementation can be found in
57
+ * mbed_critical_section_api.c. This behaviour is can be overridden on a per
58
+ * platform basis by providing a different implementation within the correct
59
+ * targets directory.
60
+ */
48
61
void hal_critical_section_enter (void );
49
62
50
- /** Mark the end of a critical section
51
- *
52
- * This function is called directly by core_util_critical_section_exit on the
53
- * final exit from a critical section.
54
- *
55
- * There is a default implementation of this function, it will restore the
56
- * state of the interrupts as they were prior to entering this critical
57
- * section, this implementation can be found in mbed_critical_section_api.c.
58
- * This behavior is overridable by providing a different function
59
- * implementation within the correct targets directory.
60
- *
61
- * This function is only called once per critical section. When implemented
62
- * for a specific platform it must restore any state that was saved upon
63
- * entering the current critical section.
64
- *
65
- */
63
+ /** Mark the end of a critical section.
64
+ *
65
+ * The purpose of this function is to restore any state that was modified upon
66
+ * entering the critical section, allowing other threads or interrupts to change
67
+ * the processor control.
68
+ *
69
+ * This function will be called once by core_util_critical_section_exit() per
70
+ * critical section on last call to exit. When called, the application MUST
71
+ * restore the saved interrupt/application state that was saved when entering
72
+ * the critical section.
73
+ *
74
+ * There is a default implementation of this function, it will restore the state
75
+ * of interrupts that were previously saved when hal_critical_section_enter was
76
+ * first called, this implementation can be found in
77
+ * mbed_critical_section_api.c. This behaviour is overridable by providing a
78
+ * different function implementation within the correct targets directory.
79
+ */
66
80
void hal_critical_section_exit (void );
67
81
68
82
/**@}*/
0 commit comments