Release 6.1.9
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
|
||||
/**************************************************************************/
|
||||
/**************************************************************************/
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** ThreadX Component */
|
||||
/** */
|
||||
/** Mutex */
|
||||
/** */
|
||||
@@ -31,48 +31,50 @@
|
||||
#include "tx_mutex.h"
|
||||
|
||||
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_mutex_put PORTABLE C */
|
||||
/**************************************************************************/
|
||||
/* */
|
||||
/* FUNCTION RELEASE */
|
||||
/* */
|
||||
/* _tx_mutex_put PORTABLE C */
|
||||
/* 6.1 */
|
||||
/* AUTHOR */
|
||||
/* */
|
||||
/* William E. Lamie, Microsoft Corporation */
|
||||
/* */
|
||||
/* DESCRIPTION */
|
||||
/* */
|
||||
/* This function puts back an instance of the specified mutex. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* mutex_ptr Pointer to mutex control block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* TX_SUCCESS Success completion status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_system_preempt_check Check for preemption */
|
||||
/* _tx_thread_system_resume Resume thread service */
|
||||
/* _tx_thread_system_ni_resume Non-interruptable resume thread */
|
||||
/* _tx_mutex_priority_change Restore previous thread priority */
|
||||
/* _tx_mutex_prioritize Prioritize the mutex suspension */
|
||||
/* _tx_mutex_thread_release Release all thread's mutexes */
|
||||
/* _tx_mutex_delete Release ownership upon mutex */
|
||||
/* deletion */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* */
|
||||
/* This function puts back an instance of the specified mutex. */
|
||||
/* */
|
||||
/* INPUT */
|
||||
/* */
|
||||
/* mutex_ptr Pointer to mutex control block */
|
||||
/* */
|
||||
/* OUTPUT */
|
||||
/* */
|
||||
/* TX_SUCCESS Success completion status */
|
||||
/* */
|
||||
/* CALLS */
|
||||
/* */
|
||||
/* _tx_thread_system_preempt_check Check for preemption */
|
||||
/* _tx_thread_system_resume Resume thread service */
|
||||
/* _tx_thread_system_ni_resume Non-interruptable resume thread */
|
||||
/* _tx_mutex_priority_change Restore previous thread priority */
|
||||
/* _tx_mutex_prioritize Prioritize the mutex suspension */
|
||||
/* _tx_mutex_thread_release Release all thread's mutexes */
|
||||
/* _tx_mutex_delete Release ownership upon mutex */
|
||||
/* deletion */
|
||||
/* */
|
||||
/* CALLED BY */
|
||||
/* */
|
||||
/* Application Code */
|
||||
/* */
|
||||
/* RELEASE HISTORY */
|
||||
/* */
|
||||
/* DATE NAME DESCRIPTION */
|
||||
/* */
|
||||
/* 09-30-2020 William E. Lamie Initial Version 6.1 */
|
||||
/* 05-19-2020 William E. Lamie Initial Version 6.0 */
|
||||
/* 09-30-2020 Yuxin Zhou Modified comment(s), */
|
||||
/* resulting in version 6.1 */
|
||||
/* */
|
||||
/**************************************************************************/
|
||||
UINT _tx_mutex_put(TX_MUTEX *mutex_ptr)
|
||||
@@ -80,11 +82,11 @@ UINT _tx_mutex_put(TX_MUTEX *mutex_ptr)
|
||||
|
||||
TX_INTERRUPT_SAVE_AREA
|
||||
|
||||
TX_THREAD *thread_ptr;
|
||||
TX_THREAD *old_owner;
|
||||
UINT old_priority;
|
||||
TX_THREAD *thread_ptr;
|
||||
TX_THREAD *old_owner;
|
||||
UINT old_priority;
|
||||
UINT status;
|
||||
TX_MUTEX *next_mutex;
|
||||
TX_MUTEX *next_mutex;
|
||||
TX_MUTEX *previous_mutex;
|
||||
UINT owned_count;
|
||||
UINT suspended_count;
|
||||
@@ -129,8 +131,8 @@ UINT inheritance_priority;
|
||||
/* Check to see if the mutex is owned by the calling thread. */
|
||||
if (mutex_ptr -> tx_mutex_owner != current_thread)
|
||||
{
|
||||
|
||||
/* Determine if the preempt disable flag is set, indicating that
|
||||
|
||||
/* Determine if the preempt disable flag is set, indicating that
|
||||
the caller is not the application but from ThreadX. In such
|
||||
cases, the thread mutex owner does not need to match. */
|
||||
if (_tx_thread_preempt_disable == ((UINT) 0))
|
||||
@@ -145,11 +147,11 @@ UINT inheritance_priority;
|
||||
status = TX_NOT_OWNED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Determine if we should continue. */
|
||||
if (status == TX_NOT_DONE)
|
||||
{
|
||||
|
||||
|
||||
/* Decrement the mutex ownership count. */
|
||||
mutex_ptr -> tx_mutex_ownership_count--;
|
||||
|
||||
@@ -164,7 +166,7 @@ UINT inheritance_priority;
|
||||
status = TX_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
|
||||
/* Check for a NULL thread pointer, which can only happen during initialization. */
|
||||
if (thread_ptr == TX_NULL)
|
||||
@@ -180,9 +182,9 @@ UINT inheritance_priority;
|
||||
{
|
||||
|
||||
/* The mutex is now available. */
|
||||
|
||||
|
||||
/* Remove this mutex from the owned mutex list. */
|
||||
|
||||
|
||||
/* Decrement the ownership count. */
|
||||
thread_ptr -> tx_thread_owned_mutex_count--;
|
||||
|
||||
@@ -209,21 +211,21 @@ UINT inheritance_priority;
|
||||
{
|
||||
|
||||
/* Yes, move the head pointer to the next link. */
|
||||
thread_ptr -> tx_thread_owned_mutex_list = next_mutex;
|
||||
thread_ptr -> tx_thread_owned_mutex_list = next_mutex;
|
||||
}
|
||||
}
|
||||
|
||||
/* Determine if the simple, non-suspension, non-priority inheritance case is present. */
|
||||
/* Determine if the simple, non-suspension, non-priority inheritance case is present. */
|
||||
if (mutex_ptr -> tx_mutex_suspension_list == TX_NULL)
|
||||
{
|
||||
|
||||
|
||||
/* Is this a priority inheritance mutex? */
|
||||
if (mutex_ptr -> tx_mutex_inherit == TX_FALSE)
|
||||
{
|
||||
|
||||
/* Yes, we are done - set the mutex owner to NULL. */
|
||||
mutex_ptr -> tx_mutex_owner = TX_NULL;
|
||||
|
||||
|
||||
/* Restore interrupts. */
|
||||
TX_RESTORE
|
||||
|
||||
@@ -231,11 +233,11 @@ UINT inheritance_priority;
|
||||
status = TX_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the processing is complete. */
|
||||
if (status == TX_NOT_DONE)
|
||||
{
|
||||
|
||||
|
||||
/* Initialize original owner and thread priority. */
|
||||
old_owner = TX_NULL;
|
||||
old_priority = thread_ptr -> tx_thread_user_priority;
|
||||
@@ -255,8 +257,8 @@ UINT inheritance_priority;
|
||||
|
||||
/* Default the inheritance priority to disabled. */
|
||||
inheritance_priority = ((UINT) TX_MAX_PRIORITIES);
|
||||
|
||||
/* Search the owned mutexes for this thread to determine the highest priority for this
|
||||
|
||||
/* Search the owned mutexes for this thread to determine the highest priority for this
|
||||
former mutex owner to return to. */
|
||||
next_mutex = thread_ptr -> tx_thread_owned_mutex_list;
|
||||
while (next_mutex != TX_NULL)
|
||||
@@ -265,8 +267,8 @@ UINT inheritance_priority;
|
||||
/* Does this mutex support priority inheritance? */
|
||||
if (next_mutex -> tx_mutex_inherit == TX_TRUE)
|
||||
{
|
||||
|
||||
/* Determine if highest priority field of the mutex is higher than the priority to
|
||||
|
||||
/* Determine if highest priority field of the mutex is higher than the priority to
|
||||
restore. */
|
||||
if (next_mutex -> tx_mutex_highest_priority_waiting < inheritance_priority)
|
||||
{
|
||||
@@ -282,7 +284,7 @@ UINT inheritance_priority;
|
||||
/* Are we at the end of the list? */
|
||||
if (next_mutex == thread_ptr -> tx_thread_owned_mutex_list)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, set the next mutex to NULL. */
|
||||
next_mutex = TX_NULL;
|
||||
}
|
||||
@@ -296,14 +298,14 @@ UINT inheritance_priority;
|
||||
/* Undo the temporarily preemption disable. */
|
||||
_tx_thread_preempt_disable--;
|
||||
#endif
|
||||
|
||||
|
||||
/* Set the inherit priority to that of the highest priority thread waiting on the mutex. */
|
||||
thread_ptr -> tx_thread_inherit_priority = inheritance_priority;
|
||||
|
||||
|
||||
/* Determine if the inheritance priority is less than the default old priority. */
|
||||
if (inheritance_priority < old_priority)
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
/* Yes, update the old priority. */
|
||||
old_priority = inheritance_priority;
|
||||
}
|
||||
@@ -330,7 +332,7 @@ UINT inheritance_priority;
|
||||
TX_RESTORE
|
||||
#endif
|
||||
|
||||
/* Call the mutex prioritize processing to ensure the
|
||||
/* Call the mutex prioritize processing to ensure the
|
||||
highest priority thread is resumed. */
|
||||
#ifdef TX_MISRA_ENABLE
|
||||
do
|
||||
@@ -360,7 +362,7 @@ UINT inheritance_priority;
|
||||
|
||||
/* Now determine if there are any threads still waiting on the mutex. */
|
||||
if (mutex_ptr -> tx_mutex_suspension_list == TX_NULL)
|
||||
{
|
||||
{
|
||||
|
||||
/* No, there are no longer any threads waiting on the mutex. */
|
||||
|
||||
@@ -368,22 +370,22 @@ UINT inheritance_priority;
|
||||
|
||||
/* Temporarily disable preemption. */
|
||||
_tx_thread_preempt_disable++;
|
||||
|
||||
|
||||
/* Restore interrupts. */
|
||||
TX_RESTORE
|
||||
#endif
|
||||
|
||||
/* Mutex is not owned, but it is possible that a thread that
|
||||
/* Mutex is not owned, but it is possible that a thread that
|
||||
caused a priority inheritance to occur is no longer waiting
|
||||
on the mutex. */
|
||||
|
||||
/* Setup the highest priority waiting thread. */
|
||||
mutex_ptr -> tx_mutex_highest_priority_waiting = (UINT) TX_MAX_PRIORITIES;
|
||||
|
||||
|
||||
/* Determine if we need to restore priority. */
|
||||
if ((mutex_ptr -> tx_mutex_owner) -> tx_thread_priority != old_priority)
|
||||
{
|
||||
|
||||
|
||||
/* Yes, restore the priority of thread. */
|
||||
_tx_mutex_priority_change(mutex_ptr -> tx_mutex_owner, old_priority);
|
||||
}
|
||||
@@ -422,14 +424,14 @@ UINT inheritance_priority;
|
||||
|
||||
/* Remember the old mutex owner. */
|
||||
old_owner = mutex_ptr -> tx_mutex_owner;
|
||||
|
||||
|
||||
/* Setup owner thread priority information. */
|
||||
mutex_ptr -> tx_mutex_original_priority = thread_ptr -> tx_thread_priority;
|
||||
|
||||
/* Setup the highest priority waiting thread. */
|
||||
mutex_ptr -> tx_mutex_highest_priority_waiting = (UINT) TX_MAX_PRIORITIES;
|
||||
}
|
||||
|
||||
|
||||
/* Determine how many mutexes are owned by this thread. */
|
||||
owned_count = thread_ptr -> tx_thread_owned_mutex_count;
|
||||
|
||||
@@ -471,7 +473,7 @@ UINT inheritance_priority;
|
||||
|
||||
/* Decrement the suspension count. */
|
||||
mutex_ptr -> tx_mutex_suspended_count--;
|
||||
|
||||
|
||||
/* Pickup the suspended count. */
|
||||
suspended_count = mutex_ptr -> tx_mutex_suspended_count;
|
||||
|
||||
@@ -480,7 +482,7 @@ UINT inheritance_priority;
|
||||
{
|
||||
|
||||
/* Yes, the only suspended thread. */
|
||||
|
||||
|
||||
/* Update the head pointer. */
|
||||
mutex_ptr -> tx_mutex_suspension_list = TX_NULL;
|
||||
}
|
||||
@@ -497,15 +499,15 @@ UINT inheritance_priority;
|
||||
previous_thread = thread_ptr -> tx_thread_suspended_previous;
|
||||
next_thread -> tx_thread_suspended_previous = previous_thread;
|
||||
previous_thread -> tx_thread_suspended_next = next_thread;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Prepare for resumption of the first thread. */
|
||||
|
||||
/* Clear cleanup routine to avoid timeout. */
|
||||
thread_ptr -> tx_thread_suspend_cleanup = TX_NULL;
|
||||
|
||||
/* Put return status into the thread control block. */
|
||||
thread_ptr -> tx_thread_suspend_status = TX_SUCCESS;
|
||||
thread_ptr -> tx_thread_suspend_status = TX_SUCCESS;
|
||||
|
||||
#ifdef TX_NOT_INTERRUPTABLE
|
||||
|
||||
@@ -534,7 +536,7 @@ UINT inheritance_priority;
|
||||
_tx_mutex_prioritize(mutex_ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Now, pickup the list head and set the priority. */
|
||||
|
||||
/* Determine if there still are threads suspended for this mutex. */
|
||||
@@ -549,11 +551,11 @@ UINT inheritance_priority;
|
||||
|
||||
/* Restore previous priority needs to be restored after priority
|
||||
inheritance. */
|
||||
|
||||
|
||||
/* Determine if we need to restore priority. */
|
||||
if (old_owner -> tx_thread_priority != old_priority)
|
||||
{
|
||||
|
||||
|
||||
/* Restore priority of thread. */
|
||||
_tx_mutex_priority_change(old_owner, old_priority);
|
||||
}
|
||||
@@ -577,7 +579,7 @@ UINT inheritance_priority;
|
||||
{
|
||||
|
||||
/* Yes, priority inheritance is requested. */
|
||||
|
||||
|
||||
/* Determine if there are any more threads still suspended on the mutex. */
|
||||
if (mutex_ptr -> tx_mutex_suspended_count != TX_NO_SUSPENSIONS)
|
||||
{
|
||||
@@ -592,7 +594,7 @@ UINT inheritance_priority;
|
||||
#else
|
||||
_tx_mutex_prioritize(mutex_ptr);
|
||||
#endif
|
||||
|
||||
|
||||
/* Now, pickup the list head and set the priority. */
|
||||
|
||||
/* Optional processing extension. */
|
||||
@@ -616,11 +618,11 @@ UINT inheritance_priority;
|
||||
|
||||
/* Restore previous priority needs to be restored after priority
|
||||
inheritance. */
|
||||
|
||||
|
||||
/* Is the priority different? */
|
||||
if (old_owner -> tx_thread_priority != old_priority)
|
||||
{
|
||||
|
||||
|
||||
/* Restore the priority of thread. */
|
||||
_tx_mutex_priority_change(old_owner, old_priority);
|
||||
}
|
||||
@@ -629,7 +631,7 @@ UINT inheritance_priority;
|
||||
/* Resume thread. */
|
||||
_tx_thread_system_resume(thread_ptr);
|
||||
#endif
|
||||
|
||||
|
||||
/* Return a successful status. */
|
||||
status = TX_SUCCESS;
|
||||
}
|
||||
@@ -643,9 +645,9 @@ UINT inheritance_priority;
|
||||
|
||||
/* Restore interrupts. */
|
||||
TX_RESTORE
|
||||
|
||||
|
||||
/* Caller does not own the mutex. */
|
||||
status = TX_NOT_OWNED;
|
||||
status = TX_NOT_OWNED;
|
||||
}
|
||||
|
||||
/* Return the completion status. */
|
||||
|
||||
Reference in New Issue
Block a user