From 02331fd30d1f1ca8c886aac4db6c8c111987913c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 17 May 2021 21:00:40 +0800 Subject: revert #3647 --- src/ipc.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 111d724c23..27ee92e3fd 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -38,7 +38,6 @@ * event without pending * 2020-10-11 Meco Man add value overflow-check code * 2021-01-03 Meco Man add rt_mb_urgent() - * 2021-01-20 hupu fix priority inversion bug of mutex */ #include @@ -192,31 +191,6 @@ rt_inline rt_err_t rt_ipc_list_resume_all(rt_list_t *list) 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 /** * 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; struct rt_thread *thread; rt_bool_t need_schedule; - rt_uint8_t max_priority_in_queue = RT_THREAD_PRIORITY_MAX - 1; /* parameter check */ RT_ASSERT(mutex != RT_NULL); @@ -917,21 +890,6 @@ rt_err_t rt_mutex_release(rt_mutex_t mutex) mutex->owner = thread; 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) { mutex->hold ++; -- cgit v1.3.1 From 5a6bc9900689ba2d21850cc520c3621c57037025 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Wed, 2 Jun 2021 15:30:32 +0800 Subject: [bug][kernel] 保持空闲任务钩子函数调用的原子性 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/clock.c | 3 ++- src/idle.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/clock.c b/src/clock.c index 045555933d..191525411a 100644 --- a/src/clock.c +++ b/src/clock.c @@ -13,7 +13,8 @@ * 2010-07-13 Bernard fix rt_tick_from_millisecond issue found by kuronca * 2011-06-26 Bernard add rt_tick_set function. * 2018-11-22 Jesven add per cpu tick - * 2020-12-29 Meco Man add function rt_tick_get_millisecond() + * 2020-12-29 Meco Man implement rt_tick_get_millisecond() + * 2021-06-01 Meco Man add critical section projection for rt_tick_increase() */ #include diff --git a/src/idle.c b/src/idle.c index 59868352d8..e73a78be9c 100644 --- a/src/idle.c +++ b/src/idle.c @@ -202,12 +202,14 @@ static void rt_thread_idle_entry(void *parameter) { #ifdef RT_USING_IDLE_HOOK rt_size_t i; + void (*idle_hook)(void); for (i = 0; i < RT_IDLE_HOOK_LIST_SIZE; i++) { - if (idle_hook_list[i] != RT_NULL) + idle_hook = idle_hook_list[i]; + if (idle_hook != RT_NULL) { - idle_hook_list[i](); + idle_hook(); } } #endif -- cgit v1.3.1 From 2b6762e85955a10e0150a3f32b869104a106acbd Mon Sep 17 00:00:00 2001 From: Meco Jianting Man <920369182@qq.com> Date: Sat, 5 Jun 2021 13:05:11 +0800 Subject: remove fix priority inversion bug of mutex --- src/ipc.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/ipc.c b/src/ipc.c index 74b47df3b6..bda32dbf26 100755 --- a/src/ipc.c +++ b/src/ipc.c @@ -39,7 +39,6 @@ * 2020-10-11 Meco Man add value overflow-check code * 2021-01-03 Meco Man implement rt_mb_urgent() * 2021-05-30 Meco Man implement rt_mutex_trytake() - * 2021-01-20 hupu fix priority inversion bug of mutex */ #include -- cgit v1.3.1 From b2dd3f00f0617abd5757ca75a5579d493dc8bd85 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 7 Jun 2021 16:45:39 +0800 Subject: [bug][kernel][heap] 将内存堆保护机制由FIFO改为PRIO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mem.c | 2 +- src/memheap.c | 2 +- src/slab.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mem.c b/src/mem.c index ac0d27f2c3..2b4d3a03be 100644 --- a/src/mem.c +++ b/src/mem.c @@ -250,7 +250,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) rt_mem_setname(heap_end, "INIT"); #endif - rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_PRIO); /* initialize the lowest-free pointer to the start of the heap */ lfree = (struct heap_mem *)heap_ptr; diff --git a/src/memheap.c b/src/memheap.c index 35a04c14b1..d3ad6d2c36 100644 --- a/src/memheap.c +++ b/src/memheap.c @@ -155,7 +155,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap, item->next_free = item->prev_free = RT_NULL; /* initialize semaphore lock */ - rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&(memheap->lock), name, 1, RT_IPC_FLAG_PRIO); RT_DEBUG_LOG(RT_DEBUG_MEMHEAP, ("memory heap: start addr 0x%08x, size %d, free list header 0x%08x\n", diff --git a/src/slab.c b/src/slab.c index 114259002f..2769892b68 100644 --- a/src/slab.c +++ b/src/slab.c @@ -363,7 +363,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr) npages = limsize / RT_MM_PAGE_SIZE; /* initialize heap semaphore */ - rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_FIFO); + rt_sem_init(&heap_sem, "heap", 1, RT_IPC_FLAG_PRIO); RT_DEBUG_LOG(RT_DEBUG_SLAB, ("heap[0x%x - 0x%x], size 0x%x, 0x%x pages\n", heap_start, heap_end, limsize, npages)); -- cgit v1.3.1