mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-28 04:27:07 +08:00
revert #3647
This commit is contained in:
parent
3baad47752
commit
02331fd30d
42
src/ipc.c
42
src/ipc.c
@ -38,7 +38,6 @@
|
|||||||
* event without pending
|
* event without pending
|
||||||
* 2020-10-11 Meco Man add value overflow-check code
|
* 2020-10-11 Meco Man add value overflow-check code
|
||||||
* 2021-01-03 Meco Man add rt_mb_urgent()
|
* 2021-01-03 Meco Man add rt_mb_urgent()
|
||||||
* 2021-01-20 hupu fix priority inversion bug of mutex
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
@ -192,31 +191,6 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list)
|
|||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This function will get the highest priority from the specified
|
|
||||||
* list of threads
|
|
||||||
*
|
|
||||||
* @param list of the threads
|
|
||||||
*
|
|
||||||
* @return the highest priority
|
|
||||||
*/
|
|
||||||
rt_uint8_t rt_ipc_get_highest_priority(rt_list_t *list)
|
|
||||||
{
|
|
||||||
struct rt_list_node *n;
|
|
||||||
struct rt_thread *sthread;
|
|
||||||
rt_uint8_t priority = RT_THREAD_PRIORITY_MAX - 1;
|
|
||||||
|
|
||||||
for (n = list->next; n != list; n = n->next)
|
|
||||||
{
|
|
||||||
sthread = rt_list_entry(n, struct rt_thread, tlist);
|
|
||||||
|
|
||||||
priority = priority < sthread->current_priority ?
|
|
||||||
priority :
|
|
||||||
sthread->current_priority;
|
|
||||||
}
|
|
||||||
return priority;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef RT_USING_SEMAPHORE
|
#ifdef RT_USING_SEMAPHORE
|
||||||
/**
|
/**
|
||||||
* This function will initialize a semaphore and put it under control of
|
* This function will initialize a semaphore and put it under control of
|
||||||
@ -855,7 +829,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
|
|||||||
register rt_base_t temp;
|
register rt_base_t temp;
|
||||||
struct rt_thread *thread;
|
struct rt_thread *thread;
|
||||||
rt_bool_t need_schedule;
|
rt_bool_t need_schedule;
|
||||||
rt_uint8_t max_priority_in_queue = RT_THREAD_PRIORITY_MAX - 1;
|
|
||||||
|
|
||||||
/* parameter check */
|
/* parameter check */
|
||||||
RT_ASSERT(mutex != RT_NULL);
|
RT_ASSERT(mutex != RT_NULL);
|
||||||
@ -917,21 +890,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex)
|
|||||||
mutex->owner = thread;
|
mutex->owner = thread;
|
||||||
mutex->original_priority = thread->current_priority;
|
mutex->original_priority = thread->current_priority;
|
||||||
|
|
||||||
/* Priority adjustment occurs only when the following conditions
|
|
||||||
* are met simultaneously:
|
|
||||||
* 1.The type of mutex is RT_IPC_FLAG_FIFO;
|
|
||||||
* 2.The priority of the thread to be resumed is not equal to the
|
|
||||||
* highest priority in the queue;
|
|
||||||
*/
|
|
||||||
max_priority_in_queue = rt_ipc_get_highest_priority(&mutex->parent.suspend_thread);
|
|
||||||
if (mutex->parent.parent.flag == RT_IPC_FLAG_FIFO &&
|
|
||||||
thread->current_priority != max_priority_in_queue)
|
|
||||||
{
|
|
||||||
rt_thread_control(thread,
|
|
||||||
RT_THREAD_CTRL_CHANGE_PRIORITY,
|
|
||||||
&(max_priority_in_queue));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mutex->hold < RT_MUTEX_HOLD_MAX)
|
if(mutex->hold < RT_MUTEX_HOLD_MAX)
|
||||||
{
|
{
|
||||||
mutex->hold ++;
|
mutex->hold ++;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user