SEGGER Embedded Studio IDE移植FreeRTOS

news/2024/5/19 1:19:51

SEGGER Embedded Studio IDE移植FreeRTOS

  • 一、简介
  • 二、技术路线
    • 2.1 获取FreeRTOS源码
    • 2.2 将必要的文件复制到工程中
      • 2.2.1 移植C文件
      • 2.2.2 移植portable文件
      • 2.2.3 移植头文件
    • 2.3 创建FreeRTOSConfig.h并进行配置
    • 2.3.1 处理中断优先级
    • 2.3.2 `configASSERT( x )`的处理
    • 2.3.3 关于系统时钟、`configCPU_CLOCK_HZ`和`configSYSTICK_CLOCK_HZ`的一点说明
    • 2.3.4 动态内存和`vApplicationGetIdleTaskMemory`符号
    • 2.3.4 操作系统那三个系统调用
    • 2.3.5 `FreeRTOSConfig.h`的代码
    • 2.4 测试
  • 三、 总结

一、简介

SEGGER Embedded Studio虽然可以支持embOS,但是我们也可能更多的时候想移植FreeRTOS。这里我把做这个移植的操作放在这里。以便未来查阅。

在本案例中,笔者不打算使用动态内存。

二、技术路线

移植的技术路线是

  1. 获取FreeRTOS源码
  2. 将必要的文件复制到工程中
  3. 创建FreeRTOSConfig.h并进行配置
  4. 测试

2.1 获取FreeRTOS源码

这一步非常简单,就是从FreeRTOS官网下载源码包。得到的源码文件里面是这个样子。
在这里插入图片描述

2.2 将必要的文件复制到工程中

2.2.1 移植C文件

参考《Mastering the FreeRTOS™ Real Time Kernel》第13页的文件结构。
在这里插入图片描述

我们把除了croutine.c的其他的文件放到项目文件夹下新建的FreeRTOS/目录下。

2.2.2 移植portable文件

一共有2个文件要用。在FreeRTOS/Source/portable/GCC/ARM-CM4F下面把cortex-m4的编译器支持包port.c和portmacro.h考过去。

记得在Project->Option->Preprocessor的User Include Directory中加入我们新建的FreeRTOS/文件夹。

因为我没有使用动态内存,所以不需要添加heap_x.c的那些文件。那些文件在FreeRTOS/Source/portable/MemMang/下面

2.2.3 移植头文件

除了那个要自己创建的FreeRTOSConfig.h,其他的在FreeRTOSv202212.01\FreeRTOS\Source\include\下面的头文件可以都考过来。虽然有那么零星的几个其实是用不上的。

2.3 创建FreeRTOSConfig.h并进行配置

这个文件必须要自己创建的。虽然官方给了很多的模板。笔者比较推荐[官方网页的模板]。(https://www.freertos.org/a00110.html)

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H/* Here is a good place to include header files that are required across
your application. */
#include "something.h"#define configUSE_PREEMPTION                    1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE                 0
#define configCPU_CLOCK_HZ                      60000000
#define configSYSTICK_CLOCK_HZ                  1000000
#define configTICK_RATE_HZ                      250
#define configMAX_PRIORITIES                    5
#define configMINIMAL_STACK_SIZE                128
#define configMAX_TASK_NAME_LEN                 16
#define configUSE_16_BIT_TICKS                  0
#define configTICK_TYPE_WIDTH_IN_BITS           TICK_TYPE_WIDTH_16_BITS
#define configIDLE_SHOULD_YIELD                 1
#define configUSE_TASK_NOTIFICATIONS            1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES   3
#define configUSE_MUTEXES                       0
#define configUSE_RECURSIVE_MUTEXES             0
#define configUSE_COUNTING_SEMAPHORES           0
#define configUSE_ALTERNATIVE_API               0 /* Deprecated! */
#define configQUEUE_REGISTRY_SIZE               10
#define configUSE_QUEUE_SETS                    0
#define configUSE_TIME_SLICING                  0
#define configUSE_NEWLIB_REENTRANT              0
#define configENABLE_BACKWARD_COMPATIBILITY     0
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
#define configUSE_MINI_LIST_ITEM                1
#define configSTACK_DEPTH_TYPE                  uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE        size_t
#define configHEAP_CLEAR_MEMORY_ON_FREE         1
#define configUSE_APPLICATION_TASK_TAG          0
#define configSTATS_BUFFER_MAX_LENGTH           0xFFFF/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION             1
#define configSUPPORT_DYNAMIC_ALLOCATION            1
#define configKERNEL_PROVIDED_STATIC_MEMORY         1
#define configTOTAL_HEAP_SIZE                       10240
#define configAPPLICATION_ALLOCATED_HEAP            1
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP   1
#define configENABLE_HEAP_PROTECTOR                 1/* Hook function related definitions. */
#define configUSE_IDLE_HOOK                     0
#define configUSE_TICK_HOOK                     0
#define configCHECK_FOR_STACK_OVERFLOW          0
#define configUSE_MALLOC_FAILED_HOOK            0
#define configUSE_DAEMON_TASK_STARTUP_HOOK      0
#define configUSE_SB_COMPLETED_CALLBACK         0/* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS           0
#define configUSE_TRACE_FACILITY                0
#define configUSE_STATS_FORMATTING_FUNCTIONS    0/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES                   0
#define configMAX_CO_ROUTINE_PRIORITIES         1/* Software timer related definitions. */
#define configUSE_TIMERS                        1
#define configTIMER_TASK_PRIORITY               3
#define configTIMER_QUEUE_LENGTH                10
#define configTIMER_TASK_STACK_DEPTH            configMINIMAL_STACK_SIZE/* Interrupt nesting behaviour configuration. */
#define configKERNEL_INTERRUPT_PRIORITY         [dependent of processor]
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    [dependent on processor and application]
#define configMAX_API_CALL_INTERRUPT_PRIORITY   [dependent on processor and application]/* Define to trap errors during development. */
#define configASSERT( ( x ) ) if( ( x ) == 0 ) vAssertCalled( __FILE__, __LINE__ )/* FreeRTOS MPU specific definitions. */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
#define configTOTAL_MPU_REGIONS                                8 /* Default value. */
#define configTEX_S_C_B_FLASH                                  0x07UL /* Default value. */
#define configTEX_S_C_B_SRAM                                   0x07UL /* Default value. */
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY            1
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS             1
#define configENABLE_ERRATA_837070_WORKAROUND                  1
#define configUSE_MPU_WRAPPERS_V1                              0
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE                10
#define configSYSTEM_CALL_STACK_SIZE                           128
#define configENABLE_ACCESS_CONTROL_LIST                       1/* ARMv8-M secure side port related definitions. */
#define secureconfigMAX_SECURE_CONTEXTS         5/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet                1
#define INCLUDE_uxTaskPriorityGet               1
#define INCLUDE_vTaskDelete                     1
#define INCLUDE_vTaskSuspend                    1
#define INCLUDE_xResumeFromISR                  1
#define INCLUDE_vTaskDelayUntil                 1
#define INCLUDE_vTaskDelay                      1
#define INCLUDE_xTaskGetSchedulerState          1
#define INCLUDE_xTaskGetCurrentTaskHandle       1
#define INCLUDE_uxTaskGetStackHighWaterMark     0
#define INCLUDE_uxTaskGetStackHighWaterMark2    0
#define INCLUDE_xTaskGetIdleTaskHandle          0
#define INCLUDE_eTaskGetState                   0
#define INCLUDE_xEventGroupSetBitFromISR        1
#define INCLUDE_xTimerPendFunctionCall          0
#define INCLUDE_xTaskAbortDelay                 0
#define INCLUDE_xTaskGetHandle                  0
#define INCLUDE_xTaskResumeFromISR              1/* A header file that defines trace macro can be included here. */#endif /* FREERTOS_CONFIG_H */

当然这个只是个模板。比较好的原因是这里面的每一个定义下面都有说明。我们稍加修改就可以了。
这里,笔者删掉了#include "something.h"

2.3.1 处理中断优先级

下面这三句

/* Interrupt nesting behaviour configuration. */
#define configKERNEL_INTERRUPT_PRIORITY         [dependent of processor]
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    [dependent on processor and application]
#define configMAX_API_CALL_INTERRUPT_PRIORITY   [dependent on processor and application]

根据stm32f407改成了

/* Interrupt nesting behaviour configuration. */
#define configKERNEL_INTERRUPT_PRIORITY         ( 15 << 4 )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    ( 5 << 4 )
#define configMAX_API_CALL_INTERRUPT_PRIORITY  

因为STM32F4的中断优先级是0 - 15,所以我设置成上面的参数。当然如果觉得不保险的话还可以参考例程。

2.3.2 configASSERT( x )的处理

这个宏的处理方法非常多。但是如果并不真的用它,可以像我这样处理。

/* Define to trap errors during development. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }

2.3.3 关于系统时钟、configCPU_CLOCK_HZconfigSYSTICK_CLOCK_HZ的一点说明

为了测试方便,笔者这里只是使用了芯片内部的RC震荡时钟。所以要把configCPU_CLOCK_HZ设置成16MHz。

关于configCPU_CLOCK_HZconfigSYSTICK_CLOCK_HZ这个的设计的初衷我不清楚。但是根据调试的效果来看,如果定义了configSYSTICK_CLOCK_HZ,系统的sysTick会使能8分频。

2.3.4 动态内存和vApplicationGetIdleTaskMemory符号

configSUPPORT_DYNAMIC_ALLOCATION关掉。但是编译后会出现要vApplicationGetIdleTaskMemory这个符号的问题。
在这里插入图片描述
参考官网上FreeRTOSConfig.h的模板的阐述,点一下configSUPPORT_STATIC_ALLOCATION的蓝字,就可以找到解决方案。就是把后面的代码加上去。
在这里插入图片描述
笔者的做法是在工程中建立一个新的文件,起名叫user_port.c,把这些代码加进去就好了。

/* configSUPPORT_STATIC_ALLOCATION is set to 1, so the application must provide an
implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
used by the Idle task. */
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer,StackType_t **ppxIdleTaskStackBuffer,configSTACK_DEPTH_TYPE *puxIdleTaskStackSize )
{
/* If the buffers to be provided to the Idle task are declared inside this
function then they must be declared static - otherwise they will be allocated on
the stack and so not exists after this function exits. */
static StaticTask_t xIdleTaskTCB;
static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];/* Pass out a pointer to the StaticTask_t structure in which the Idle task'sstate will be stored. */*ppxIdleTaskTCBBuffer = &xIdleTaskTCB;/* Pass out the array that will be used as the Idle task's stack. */*ppxIdleTaskStackBuffer = uxIdleTaskStack;/* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.Note that, as the array is necessarily of type StackType_t,configMINIMAL_STACK_SIZE is specified in words, not bytes. */*puxIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}
/*-----------------------------------------------------------*//* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
application must provide an implementation of vApplicationGetTimerTaskMemory()
to provide the memory that is used by the Timer service task. */
void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,StackType_t **ppxTimerTaskStackBuffer,configSTACK_DEPTH_TYPE *puxTimerTaskStackSize )
{
/* If the buffers to be provided to the Timer task are declared inside this
function then they must be declared static - otherwise they will be allocated on
the stack and so not exists after this function exits. */
static StaticTask_t xTimerTaskTCB;
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];/* Pass out a pointer to the StaticTask_t structure in which the Timertask's state will be stored. */*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;/* Pass out the array that will be used as the Timer task's stack. */*ppxTimerTaskStackBuffer = uxTimerTaskStack;/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.Note that, as the array is necessarily of type StackType_t,configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */*puxTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
}

2.3.4 操作系统那三个系统调用

我们都知道,RTOS的运行离不开SVC_Handler、PendSV_Handler和SysTick_Handler。但是系统已经给实现了vPortSVCHandler、xPortPendSVHandler和xPortSysTickHandler。这里只要用#define把名称对应一下就可以了。

/* A header file that defines trace macro can be included here. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler

2.3.5 FreeRTOSConfig.h的代码

根据上面的操作,笔者最后的FreeRTOSConfig.h的代码如下所示

#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H/* Here is a good place to include header files that are required across
your application. */#define configUSE_PREEMPTION                    1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configUSE_TICKLESS_IDLE                 0
#define configCPU_CLOCK_HZ                      16000000
//#define configSYSTICK_CLOCK_HZ                  16000000
#define configTICK_RATE_HZ                      1000
#define configMAX_PRIORITIES                    255
#define configMINIMAL_STACK_SIZE                128
#define configMAX_TASK_NAME_LEN                 16
#define configUSE_16_BIT_TICKS                  0
#define configTICK_TYPE_WIDTH_IN_BITS           TICK_TYPE_WIDTH_16_BITS
#define configIDLE_SHOULD_YIELD                 1
#define configUSE_TASK_NOTIFICATIONS            1
#define configTASK_NOTIFICATION_ARRAY_ENTRIES   3
#define configUSE_MUTEXES                       0
#define configUSE_RECURSIVE_MUTEXES             0
#define configUSE_COUNTING_SEMAPHORES           0
#define configUSE_ALTERNATIVE_API               0 /* Deprecated! */
#define configQUEUE_REGISTRY_SIZE               10
#define configUSE_QUEUE_SETS                    0
#define configUSE_TIME_SLICING                  0
#define configUSE_NEWLIB_REENTRANT              0
#define configENABLE_BACKWARD_COMPATIBILITY     0
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5
#define configUSE_MINI_LIST_ITEM                1
#define configSTACK_DEPTH_TYPE                  uint32_t
#define configMESSAGE_BUFFER_LENGTH_TYPE        size_t
#define configHEAP_CLEAR_MEMORY_ON_FREE         1
#define configUSE_APPLICATION_TASK_TAG          0
#define configSTATS_BUFFER_MAX_LENGTH           0xFFFF/* Memory allocation related definitions. */
#define configSUPPORT_STATIC_ALLOCATION             1
#define configSUPPORT_DYNAMIC_ALLOCATION            0
#define configKERNEL_PROVIDED_STATIC_MEMORY         1
#define configTOTAL_HEAP_SIZE                       1024
#define configAPPLICATION_ALLOCATED_HEAP            1
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP   1
#define configENABLE_HEAP_PROTECTOR                 1/* Hook function related definitions. */
#define configUSE_IDLE_HOOK                     0
#define configUSE_TICK_HOOK                     0
#define configCHECK_FOR_STACK_OVERFLOW          0
#define configUSE_MALLOC_FAILED_HOOK            0
#define configUSE_DAEMON_TASK_STARTUP_HOOK      0
#define configUSE_SB_COMPLETED_CALLBACK         0/* Run time and task stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS           0
#define configUSE_TRACE_FACILITY                0
#define configUSE_STATS_FORMATTING_FUNCTIONS    0/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES                   0
#define configMAX_CO_ROUTINE_PRIORITIES         1/* Software timer related definitions. */
#define configUSE_TIMERS                        1
#define configTIMER_TASK_PRIORITY               3
#define configTIMER_QUEUE_LENGTH                10
#define configTIMER_TASK_STACK_DEPTH            configMINIMAL_STACK_SIZE/* Interrupt nesting behaviour configuration. */
#define configKERNEL_INTERRUPT_PRIORITY         ( 15 )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    ( 5 )
#define configMAX_API_CALL_INTERRUPT_PRIORITY   /* Define to trap errors during development. */
#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }/* FreeRTOS MPU specific definitions. */
#define configINCLUDE_APPLICATION_DEFINED_PRIVILEGED_FUNCTIONS 0
#define configTOTAL_MPU_REGIONS                                8 /* Default value. */
#define configTEX_S_C_B_FLASH                                  0x07UL /* Default value. */
#define configTEX_S_C_B_SRAM                                   0x07UL /* Default value. */
#define configENFORCE_SYSTEM_CALLS_FROM_KERNEL_ONLY            1
#define configALLOW_UNPRIVILEGED_CRITICAL_SECTIONS             1
#define configENABLE_ERRATA_837070_WORKAROUND                  1
#define configUSE_MPU_WRAPPERS_V1                              0
#define configPROTECTED_KERNEL_OBJECT_POOL_SIZE                10
#define configSYSTEM_CALL_STACK_SIZE                           128
#define configENABLE_ACCESS_CONTROL_LIST                       1/* ARMv8-M secure side port related definitions. */
#define secureconfigMAX_SECURE_CONTEXTS         5/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet                1
#define INCLUDE_uxTaskPriorityGet               1
#define INCLUDE_vTaskDelete                     1
#define INCLUDE_vTaskSuspend                    1
#define INCLUDE_xResumeFromISR                  1
#define INCLUDE_vTaskDelayUntil                 1
#define INCLUDE_vTaskDelay                      1
#define INCLUDE_xTaskGetSchedulerState          1
#define INCLUDE_xTaskGetCurrentTaskHandle       1
#define INCLUDE_uxTaskGetStackHighWaterMark     0
#define INCLUDE_uxTaskGetStackHighWaterMark2    0
#define INCLUDE_xTaskGetIdleTaskHandle          0
#define INCLUDE_eTaskGetState                   0
#define INCLUDE_xEventGroupSetBitFromISR        1
#define INCLUDE_xTimerPendFunctionCall          0
#define INCLUDE_xTaskAbortDelay                 0
#define INCLUDE_xTaskGetHandle                  0
#define INCLUDE_xTaskResumeFromISR              1/* A header file that defines trace macro can be included here. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
#endif /* FREERTOS_CONFIG_H */

2.4 测试

参考手册,做了下面的这样一个测试用例。

/*********************************************************************
*                    SEGGER Microcontroller GmbH                     *
*                        The Embedded Experts                        *
**********************************************************************-------------------------- END-OF-HEADER -----------------------------File    : main.c
Purpose : Generic application start*/#include "stm32f407xx.h" 
#include <stdio.h>
#include <stdlib.h>
#include "FreeRTOS.h"
#include "task.h"
#include "hardware.h"/*********************************************************************
*
*       main()
*
*  Function description
*   Application entry point.
*
**********************************************************************/#define STACK_SIZE 200
static void vTaskMain(void *p);
static StaticTask_t xTaskBuffer;
static StackType_t xStack[ STACK_SIZE ];int main(void) {int i;SystemCoreClockUpdate();prvSetupHardware();TaskHandle_t xHandle = NULL;/* Create the task without using any dynamic memory allocation. */xHandle = xTaskCreateStatic(vTaskMain,              /* Function that implements the task. */"NAME",                 /* Text name for the task. */STACK_SIZE,             /* The number of indexes in the xStack array. */( void * ) 1,           /* Parameter passed into the task. */155,       /* Priority at which the task is created. */xStack,                 /* Array to use as the task's stack. */&xTaskBuffer );         /* Variable to hold the task's data structure. */vTaskStartScheduler();while(1);
}void vTaskMain(void *p){while(1){GPIOA->BSRR = 1<<7;vTaskDelay(pdMS_TO_TICKS(10));GPIOA->BSRR = 1<<7<<16;vTaskDelay(pdMS_TO_TICKS(20));}
}/*************************** End of file ****************************/

运行,用示波器测PA7的输出。
在这里插入图片描述

三、 总结

根据上述步骤,完成FreeRTOS的移植。但是本例子中没有采用到动态内存。如果要启动动态内存,就在FreeRTOSConfig.h中把configSUPPORT_DYNAMIC_ALLOCATION这一项启用;将heap_x.c挑1个放入工程文件夹中;手动实现vPortFree函数。这次这里就不做介绍。


http://www.mrgr.cn/p/30421620

相关文章

mybatis中<if>条件判断带数字的字符串失效问题

文章目录 一、项目背景二、真实错误原因说明三、解决方案3.1针对纯数字的字符串值场景3.2针对单个字符的字符串值场景 四、参考文献 一、项目背景 MySQL数据库使用Mybatis查询拼接select语句中进行<if>条件拼接的时候&#xff0c;发现带数字的或者带单个字母的字符串失效…

md5绕过

md5绕过 ($a != $b && md5($a) == md5($b))的绕过 传参a=s1885207154a,b=s1836677006aMD5值:md5("s1885207154a") => 0e509367213418206700842008763514md5("s1836677006a") => 0e481036490867661113260034900752在PHP中 0e开头表示为科学…

Hadoop——Yarn基础架构

Hadoop——Yarn基础架构 Hadoop YARN&#xff08;Yet Another Resource Negotiator&#xff09;是Apache Hadoop生态系统中的一个子项目&#xff0c;它是用于集群资源管理的框架&#xff0c;负责为运算程序提供服务器运算资源&#xff0c;相当于一个分布式的操作系统平台&…

js的算法-交换排序(冒泡)

交换排序 所谓交换排序&#xff0c;是指根据序列中两个元素关键字的比较结果来对换这两个记录在序列中的位置。基于交换的排序算法很多&#xff0c;本次介绍冒泡排序和快速排序。 冒泡 基本思想 从后往前&#xff08;或从前往后&#xff09;两两比较相邻元素的值&#xff0…

01_Linux最简单驱动-helloworld

Linux最简单驱动-helloworld 驱动分为四个部分: ​ 头文件 ​ 驱动模块的入口和出口 ​ 声明信息 ​ 功能实现 第一步,包含头文件 #include <linux/init.h> 包含宏定义的头文件 #include <linux/module.h> 包含初始化加载模块的头文件 第二步,驱动模块的入口和出…

《QT实用小工具·四十二》圆形发光图像

1、概述 源码放在文章末尾 该项目实现了图像的发光效果&#xff0c;特别适合做头像&#xff0c;项目demo演示如下所示&#xff1a; 项目部分代码如下所示&#xff1a; import QtQuick 2.7 import QtGraphicalEffects 1.12Item {id: rootwidth: 80height: 80property int ra…

Grid 布局

文章目录 容器属性display 属性grid-template-columns 和 grid-template-rows 属性row-gap、column-gap、gap 属性grid-template-areas 属性grid-auto-flow 属性justify-items、align-items、place-items 属性justify-content、align-content、place-content 属性grid-auto-col…

KNN算法思想与Python实现

古语说得好,物以类聚,人以群分;近朱者赤,近墨者黑。这两句话的大概意思就是,你周围大部分朋友是什么人,那么你大概率也就是这种人,这句话其实也就是K最近邻算法的核心思想。kNN(k- Nearest Neighbor)法即k最邻近法,最初由 Cover和Hart于1968年提出,是一个理论上比较…

数据结构练习-算法与时间复杂度

----------------------------------------------------------------------------------------------------------------------------- 1. 设n是描述问题规模的非负整数&#xff0c;下列程序段的时间复杂度是( )。 x0;while(n>(x1)*(x1)xx1; A.O(logn) B.O(n^(1/2)) C.O(n)…

递归神经网络(RNN)在AI去衣技术中的深度应用

在人工智能&#xff08;AI&#xff09;技术飞速发展的今天&#xff0c;图像处理和计算机视觉领域不断取得新的突破。其中&#xff0c;AI去衣技术作为一个具有挑战性的研究方向&#xff0c;引起了广大研究者和公众的关注。递归神经网络&#xff08;RNN&#xff09;作为深度学习的…

HarmonyOS 应用生命周期有哪些? 按返回键会调用哪些生命周期?

UIAbility 生命周期:onCreate :页面初始化,变量定义,资源加载。 onWindowStageCreate:设置 UI 界面加载、设置 WindowStage 的事件订阅。 onForeground:切换至前台,申请系统需要的资源,或者重新申请在 onBackground()中释放的资源。 onBackground:切换至后台,释放 U…

(007)Blender 根据顶点组分离模型

1.选中模型&#xff0c;并且进入【3D视图】【编辑模式】&#xff1a; 2.选择顶点组&#xff1a; 3.分离选中项&#xff1a;

DRF之过滤 排序 分页

DRF之过滤 排序 分页使用【过滤 排序 分页】都需要在继承了GenericAPIView的视图类下使用 并指定类属性【queryset 和 serializer_class】【一】过滤 # 所有过滤类都继承 【BaseFilterBackend】 from rest_framework.filters import BaseFilterBackend【1】drf自带的过滤 # 导入…

图文结合手把手教你创建SpringCloud项目

前言 什么是SpringCloud? Spring Cloud 是一系列框架的有序集合,它利用 Spring Boot 的开发便利性简化了分布式系统的开发,比如服务注册、服务发现、网关、路由、链路追踪等。Spring Cloud 并不是重复造轮子,而是将市面上开发得比较好的模块集成进去,进行封装,从而减少了…

redis中的缓存穿透问题

缓存穿透 缓存穿透问题&#xff1a; 一般请求来到后端&#xff0c;都是先从缓存中查找数据&#xff0c;如果缓存中找不到&#xff0c;才会去数据库中查询数据。 而缓存穿透就是基于这一点&#xff0c;不断发送请求查询不存在的数据&#xff0c;从而使数据库压力过大&#xff…

ubuntu无法用快捷键启动终端(CTRL+AIT+T)

我的电脑不知道安装什么东西之后&#xff0c;就不能用快捷键&#xff08;CTRLAITT&#xff09;打开终端了 只能在文件夹内&#xff0c;点击鼠标右键选择终端&#xff0c;然后打开终端 一直这么用了几个月&#xff0c;今天实在受不了了&#xff0c;所以解决此问题 本文参考文章…

力扣-118. 杨辉三角

1.题目介绍 题目地址(118. 杨辉三角 - 力扣(LeetCode)) https://leetcode.cn/problems/pascals-triangle/ 题目描述 给定一个非负整数 numRows,生成「杨辉三角」的前 numRows 行。 在「杨辉三角」中,每个数是它左上方和右上方的数的和。 示例 1: 输入: numRows = 5 输出: …

IDEA中springboot项目编译两次的问题

原因:因为在导入项目的之后,项目无法运行,问题1:显示缺少org.springbootframe的依赖,不知道怎么解决,网上搜了个方法,就是勾选下图的选项,意思是把build操作由IDEA交给Maven,勾选之后确实可以启动项目了但是后面在执行Mybatis时,问题2:我发现无论如何都会报一个唯一…

深入刨析 mysql 底层索引结构B+树

文章目录 前言一、什么是索引&#xff1f;二、不同索引结构对比2.1 二叉树2.2 平衡二叉树2.3 B-树2.4 B树 三、mysql 的索引3.1 聚簇索引3.2 非聚簇索引 前言 很多人看过mysql索引的介绍&#xff1a;hash表、B-树、B树、聚簇索引、主键索引、唯一索引、辅助索引、二级索引、联…

计算机为什么需要中断?

// generated by ChatGPT-3.5 & hk416hasu中断是计算机系统中一种重要的机制,它允许系统在执行过程中临时中止当前任务,转而处理其他优先级更高或更紧急的任务,然后再返回原来的任务。以下是一些计算机需要中断的原因:1. 响应外部事件:计算机系统需要能够响应各种外部…