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

@ -30,38 +30,52 @@ 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
* processor by preventing any change in processor control, the default
* behaviour requires storing the state of interrupts in the system before
* disabling them.
* *
* There is a default implementation of this function which will save the * The critical section code supports nesting. When a thread has entered a
* current state of interrupts before disabling them. This implementation can * critical section it can make additional calls to
* be found in mbed_critical_section_api.c. This behaviour is can be overridden * core_util_critical_section_enter() without deadlocking itself. The critical
* on a per platform basis by providing a different implementation within the * section driver API tracks the number of nested calls to the critical section.
* correct targets directory. * The critical section will only be exited when
* core_util_critical_section_exit() has been called once for each time it
* entered the critical section.
* *
* The function is only called once per critical section by * On the first call to enter a critical section this function MUST store the
* core_util_critical_section_enter. When implementing this function for a * state of any interrupts or other application settings it will modify to
* platform you must store any state that you intend to alter within this * facilitate the critical section.
* function so it can be restored when exiting 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 * This function will be called once by core_util_critical_section_exit() per
* state of the interrupts as they were prior to entering this critical * critical section on last call to exit. When called, the application MUST
* section, this implementation can be found in mbed_critical_section_api.c. * restore the saved interrupt/application state that was saved when entering
* This behavior is overridable by providing a different function * the critical section.
* implementation within the correct targets directory.
*
* This function is only called once per critical section. When implemented
* for a specific platform it must restore any state that was saved upon
* entering the current critical section.
* *
* There is a default implementation of this function, it will restore the state
* of interrupts that were previously saved when hal_critical_section_enter was
* 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);