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: [PATCH 1/6] revert #3647 --- src/ipc.c | 42 ------------------------------------------ 1 file changed, 42 deletions(-) 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 ++; 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: [PATCH 2/6] =?UTF-8?q?[bug][kernel]=20=E4=BF=9D=E6=8C=81=E7=A9=BA?= =?UTF-8?q?=E9=97=B2=E4=BB=BB=E5=8A=A1=E9=92=A9=E5=AD=90=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=9A=84=E5=8E=9F=E5=AD=90=E6=80=A7?= 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(-) 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 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: [PATCH 3/6] remove fix priority inversion bug of mutex --- src/ipc.c | 1 - 1 file changed, 1 deletion(-) 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 From 1e82e40c82925059e1cb0115bc28224bee038dda Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 7 Jun 2021 11:37:12 +0800 Subject: [PATCH 4/6] fixed bug of lcd_draw_line function when y1 == y2. need to consider user case when x1 >= x2 --- .../board/ports/drv_lcd.c | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c index f80ca3a4b2..6ec90f880c 100644 --- a/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c +++ b/bsp/stm32/stm32l475-atk-pandora/board/ports/drv_lcd.c @@ -446,18 +446,33 @@ void lcd_draw_line(rt_uint16_t x1, rt_uint16_t y1, rt_uint16_t x2, rt_uint16_t y if (y1 == y2) { /* fast draw transverse line */ - lcd_address_set(x1, y1, x2, y2); + rt_uint32_t x_offset = 0; + if (x1 < x2) + { + x_offset = x2 - x1; + lcd_address_set(x1, y1, x2, y2); + } + else if (x1 > x2) + { + x_offset = x1 - x2; + lcd_address_set(x2, y2, x1, y1); + } + else + { + lcd_draw_point(x1, y1); + return; + } rt_uint8_t line_buf[480] = {0}; - for (i = 0; i < x2 - x1; i++) + for (i = 0; i < x_offset; i++) { line_buf[2 * i] = FORE_COLOR >> 8; line_buf[2 * i + 1] = FORE_COLOR; } rt_pin_write(LCD_DC_PIN, PIN_HIGH); - rt_spi_send(spi_dev_lcd, line_buf, (x2 - x1) * 2); + rt_spi_send(spi_dev_lcd, line_buf, x_offset * 2); return ; } From 115ec7cf49650e3206510b63e2a527d0ddc626ea Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 7 Jun 2021 12:58:17 +0800 Subject: [PATCH 5/6] [tools] remove formatting --- tools/formatting.py | 135 -------------------------------------------- 1 file changed, 135 deletions(-) delete mode 100644 tools/formatting.py diff --git a/tools/formatting.py b/tools/formatting.py deleted file mode 100644 index 0b63e031fa..0000000000 --- a/tools/formatting.py +++ /dev/null @@ -1,135 +0,0 @@ -# -# File : formatting.py -# This file is part of RT-Thread RTOS -# COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Change Logs: -# Date Author Notes -# 2021-03-02 Meco Man The first version -# 2021-03-04 Meco Man 增加统一转换成UTF-8编码格式功能 - - -#本文件会自动对指定路径下的所有文件包括子文件夹的文件(仅针对.c.h)进行扫描 -# 1)将源文件编码统一为UTF-8; -# 2)将TAB键替换为空格; -# 3)将每行末尾多余的空格删除,并统一换行符为'\n'; -#使用时只需要双击本文件,输入要扫描的文件夹路径即可 -#不能保证100%全部成功转换为UTF-8,有一些编码特殊或识别不准确会在终端打印信息,需人工转换 - -#欢迎对本文件的功能继续做出补充,欢迎提交PR - -import os -import chardet - -#用空格代替TAB键 -#这里并不是简单的将TAB替换成4个空格 -#空格个数到底是多少需要计算,因为TAB制表本身有自动对齐的功能 -def tab2spaces(line): - list_str = list(line) #字符串打散成列表,放边操作 - i = list_str.count('\t') - - while i > 0: - ptr = list_str.index('\t') - del list_str[ptr] - space_need_to_insert = 4 - (ptr%4) - j = 0 - while j < space_need_to_insert: - list_str.insert(ptr,' ') - j = j+1 - - i = i-1 - - line = ''.join(list_str) #列表恢复成字符串 - return line - -#删除每行末尾多余的空格 统一使用\n作为结尾 -def formattail(line): - line = line.rstrip() - line = line + '\n' - return line - -#对单个文件进行格式整理 -def format_codes(filename): - try: - file=open(filename,'r',encoding = 'utf-8') - file_temp=open('temp','w',encoding = 'utf-8') - for line in file: - line = tab2spaces(line) - line = formattail(line) - file_temp.write(line) - file_temp.close() - file.close() - os.remove(filename) - os.rename('temp',filename) - -def get_encode_info(file): - with open(file, 'rb') as f: - code = chardet.detect(f.read())['encoding'] - #charde库有一定几率对当前文件的编码识别不准确 - if code == 'EUC-JP': #容易将含着少量中文的英文字符文档识别为日语编码格式 - code = 'GB2312' - elif code == 'ISO-8859-1': #部分文件GB2312码会被识别成ISO-8859-1 - code = 'GB2312' - - if not (code == 'ascii' or code == 'utf-8' or code == 'GB2312' #编码识别正确 - or code == 'Windows-1252'): # Windows-1252 是由于意法半导体是法国企业's的'是法语的'导致的 - if code != None: - print('未处理,需人工确认:'+code+':'+file) #需要人工确认 - code = None - - return code - -#将单个文件转为UTF-8编码 -def conver_to_utf_8 (path): - try: - info = get_encode_info(path) - if info == None: - return 0 #0 失败 - - file=open(path,'rb+') - data = file.read() - string = data.decode(info) - utf = string.encode('utf-8') - file.seek(0) - file.write(utf) - file.close() - return 1 #1成功 - except UnicodeDecodeError: - print("UnicodeDecodeError未处理,需人工确认"+path) - return 0 - except UnicodeEncodeError: - print("UnicodeEncodeError未处理,需人工确认"+path) - return 0 - -# 递归扫描目录下的所有文件 -def traversalallfile(path): - filelist=os.listdir(path) - for file in filelist: - filepath=os.path.join(path,file) - if os.path.isdir(filepath): - traversalallfile(filepath) - elif os.path.isfile(filepath): - if filepath.endswith(".c") == True or filepath.endswith(".h") == True: #只处理.c和.h文件 - if conver_to_utf_8(filepath) == 1: #先把这个文件转为UTF-8编码,1成功 - format_codes(filepath) #再对这个文件进行格式整理 - -def formatfiles(): - workpath = input('enter work path: ') - traversalallfile(workpath) - -if __name__ == '__main__': - formatfiles() 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: [PATCH 6/6] =?UTF-8?q?[bug][kernel][heap]=20=E5=B0=86=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=A0=86=E4=BF=9D=E6=8A=A4=E6=9C=BA=E5=88=B6=E7=94=B1?= =?UTF-8?q?FIFO=E6=94=B9=E4=B8=BAPRIO?= 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(-) 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));