Amend critical section function descriptions

pull/5346/head
Steven Cartmell 2017-12-20 16:21:58 +00:00
parent e14bee5209
commit 04d2f3de78
1 changed files with 47 additions and 33 deletions

View File

@ -28,41 +28,55 @@ extern "C" {
*/ */
/** /**
* Mark the start of a critical section * Mark the start of a critical section
* *
* This function is called directly by core_util_critical_section_enter on * This function will be called by core_util_critical_section_enter() each time
* first entrance to a critical section. * the application requests to enter a critical section. The purpose of the
* * critical section is to ensure mutual-exclusion synchronisation of the
* There is a default implementation of this function which will save the * processor by preventing any change in processor control, the default
* current state of interrupts before disabling them. This implementation can * behaviour requires storing the state of interrupts in the system before
* be found in mbed_critical_section_api.c. This behaviour is can be overridden * disabling them.
* on a per platform basis by providing a different implementation within the *
* correct targets directory. * The critical section code supports nesting. When a thread has entered a
* * critical section it can make additional calls to
* The function is only called once per critical section by * core_util_critical_section_enter() without deadlocking itself. The critical
* core_util_critical_section_enter. When implementing this function for a * section driver API tracks the number of nested calls to the critical section.
* platform you must store any state that you intend to alter within this * The critical section will only be exited when
* function so it can be restored when exiting the critical section. * core_util_critical_section_exit() has been called once for each time it
* * entered the critical section.
*/ *
* On the first call to enter a critical section this function MUST store the
* state of any interrupts or other application settings it will modify to
* facilitate the critical section.
*
* Each successive call to enter the critical section MUST ignore storing or
* modifying any application state.
*
* The default implementation of this function which will save the current state
* of interrupts before disabling them. This implementation can be found in
* mbed_critical_section_api.c. This behaviour is can be overridden on a per
* platform basis by providing a different implementation within the correct
* targets directory.
*/
void hal_critical_section_enter(void); void hal_critical_section_enter(void);
/** Mark the end of a critical section /** Mark the end of a critical section.
* *
* This function is called directly by core_util_critical_section_exit on the * The purpose of this function is to restore any state that was modified upon
* final exit from a critical section. * entering the critical section, allowing other threads or interrupts to change
* * the processor control.
* There is a default implementation of this function, it will restore the *
* state of the interrupts as they were prior to entering this critical * This function will be called once by core_util_critical_section_exit() per
* section, this implementation can be found in mbed_critical_section_api.c. * critical section on last call to exit. When called, the application MUST
* This behavior is overridable by providing a different function * restore the saved interrupt/application state that was saved when entering
* implementation within the correct targets directory. * the critical section.
* *
* This function is only called once per critical section. When implemented * There is a default implementation of this function, it will restore the state
* for a specific platform it must restore any state that was saved upon * of interrupts that were previously saved when hal_critical_section_enter was
* entering the current critical section. * first called, this implementation can be found in
* * mbed_critical_section_api.c. This behaviour is overridable by providing a
*/ * different function implementation within the correct targets directory.
*/
void hal_critical_section_exit(void); void hal_critical_section_exit(void);
/**@}*/ /**@}*/