update change prio func
This commit is contained in:
parent
9a84c13b2e
commit
b1b54629dc
|
@ -168,6 +168,7 @@ rt_err_t rt_sched_thread_close(struct rt_thread *thread);
|
||||||
rt_err_t rt_sched_thread_ready(struct rt_thread *thread);
|
rt_err_t rt_sched_thread_ready(struct rt_thread *thread);
|
||||||
rt_err_t rt_sched_thread_suspend(struct rt_thread *thread, rt_sched_lock_level_t level);
|
rt_err_t rt_sched_thread_suspend(struct rt_thread *thread, rt_sched_lock_level_t level);
|
||||||
rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t priority);
|
rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t priority);
|
||||||
|
rt_err_t rt_sched_thread_change_curr_priority(struct rt_thread *thread, rt_uint8_t priority);
|
||||||
rt_err_t rt_sched_thread_bind_cpu(struct rt_thread *thread, int cpu);
|
rt_err_t rt_sched_thread_bind_cpu(struct rt_thread *thread, int cpu);
|
||||||
rt_uint8_t rt_sched_thread_is_suspended(struct rt_thread *thread);
|
rt_uint8_t rt_sched_thread_is_suspended(struct rt_thread *thread);
|
||||||
rt_err_t rt_sched_thread_timer_stop(struct rt_thread *thread);
|
rt_err_t rt_sched_thread_timer_stop(struct rt_thread *thread);
|
||||||
|
|
|
@ -873,7 +873,7 @@ rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t prio
|
||||||
LOG_D("thread:%s priority -> %d", thread->parent.name, priority);
|
LOG_D("thread:%s priority -> %d", thread->parent.name, priority);
|
||||||
|
|
||||||
/* change priority of the thread */
|
/* change priority of the thread */
|
||||||
ret = rt_sched_thread_change_priority(thread, priority);
|
ret = rt_sched_thread_change_curr_priority(thread, priority);
|
||||||
|
|
||||||
while ((ret == RT_EOK) && rt_sched_thread_is_suspended(thread))
|
while ((ret == RT_EOK) && rt_sched_thread_is_suspended(thread))
|
||||||
{
|
{
|
||||||
|
@ -904,7 +904,7 @@ rt_inline void _thread_update_priority(struct rt_thread *thread, rt_uint8_t prio
|
||||||
{
|
{
|
||||||
thread = pending_mutex->owner;
|
thread = pending_mutex->owner;
|
||||||
|
|
||||||
ret = rt_sched_thread_change_priority(thread, mutex_priority);
|
ret = rt_sched_thread_change_curr_priority(thread, mutex_priority);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -931,7 +931,7 @@ static rt_bool_t _check_and_update_prio(rt_thread_t thread, rt_mutex_t mutex)
|
||||||
/* get the highest priority in the taken list of thread */
|
/* get the highest priority in the taken list of thread */
|
||||||
priority = _thread_get_mutex_priority(thread);
|
priority = _thread_get_mutex_priority(thread);
|
||||||
|
|
||||||
rt_sched_thread_change_priority(thread, priority);
|
rt_sched_thread_change_curr_priority(thread, priority);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notify a pending reschedule. Since scheduler is locked, we will not
|
* notify a pending reschedule. Since scheduler is locked, we will not
|
||||||
|
|
|
@ -180,7 +180,7 @@ rt_err_t rt_sched_tick_increase(rt_tick_t tick)
|
||||||
/**
|
/**
|
||||||
* @brief Update priority of the target thread
|
* @brief Update priority of the target thread
|
||||||
*/
|
*/
|
||||||
rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t priority)
|
rt_err_t rt_sched_thread_change_curr_priority(struct rt_thread *thread, rt_uint8_t priority)
|
||||||
{
|
{
|
||||||
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
|
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
|
||||||
RT_SCHED_DEBUG_IS_LOCKED;
|
RT_SCHED_DEBUG_IS_LOCKED;
|
||||||
|
@ -224,6 +224,26 @@ rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t pr
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update priority of the target thread
|
||||||
|
*/
|
||||||
|
rt_err_t rt_sched_thread_change_priority(struct rt_thread *thread, rt_uint8_t priority)
|
||||||
|
{
|
||||||
|
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
|
||||||
|
RT_SCHED_DEBUG_IS_LOCKED;
|
||||||
|
|
||||||
|
/* change thread init priority */
|
||||||
|
RT_SCHED_PRIV(thread).init_priority = priority;
|
||||||
|
|
||||||
|
/* if this thread takes mutex, its current prio is controlled by mutex PI protocol */
|
||||||
|
if (rt_list_isempty(&thread->taken_object_list) && !(thread->pending_object && (rt_object_get_type(thread->pending_object) == RT_Object_Class_Mutex)))
|
||||||
|
{
|
||||||
|
rt_sched_thread_change_curr_priority(thread, priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef RT_USING_OVERFLOW_CHECK
|
#ifdef RT_USING_OVERFLOW_CHECK
|
||||||
void rt_scheduler_stack_check(struct rt_thread *thread)
|
void rt_scheduler_stack_check(struct rt_thread *thread)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue