fix a tick list add bug

fix a tick list add bug: if a lower priority task has the same tick_expires with a higher priority task in the tick list, the lower should be added behind the higher one.
This commit is contained in:
SheldonDai
2019-09-23 20:40:31 +08:00
parent 45e8c1e6af
commit 4cfe60a9cb
3 changed files with 6 additions and 2 deletions

View File

@@ -48,7 +48,7 @@ typedef void (*k_task_entry_t)(void *arg);
* task control block * task control block
*/ */
typedef struct k_task_st { typedef struct k_task_st {
k_stack_t *sp; /**< task stack pointer. This lady always comes first, we use her in port_s.S for context switch. */ k_stack_t *sp; /**< task stack pointer. This lady always comes first, we count on her in port_s.S for context switch. */
#if TOS_CFG_OBJECT_VERIFY_EN > 0u #if TOS_CFG_OBJECT_VERIFY_EN > 0u
knl_obj_t knl_obj; /**< just for verification, test whether current object is really a task. */ knl_obj_t knl_obj; /**< just for verification, test whether current object is really a task. */

View File

@@ -18,6 +18,10 @@ __STATIC__ void tick_task_place(k_task_t *task, k_tick_t timeout)
if (task->tick_expires < curr_expires) { if (task->tick_expires < curr_expires) {
break; break;
} }
if (task->tick_expires == curr_expires &&
task->prio < curr_task->prio) {
break;
}
prev_expires = curr_expires; prev_expires = curr_expires;
} }
task->tick_expires -= prev_expires; task->tick_expires -= prev_expires;