I.MX6ULL 中断介绍上

i.MX6ULL是NXP(原Freescale)推出的一款基于ARM Cortex-A7内核的微处理器,广泛应用于嵌入式系统。在i.MX6ULL中,中断(Interrupt)是一种重要的机制,用于处理外部或内部事件,允许微处理器在执行当前任务的同时,能够及时响应其他紧急任务或外部设备的请求。

中断的概念:

中断是计算机系统中的一种关键机制,它允许在程序执行过程中,当特定事件或条件发生时,处理器能够暂停当前正在运行的程序,转而去处理这些紧急或高优先级的事件。处理完这些事件后,处理器会返回到被中断的程序继续执行。

中断机制是现代计算机系统的基础,它使得系统能够及时响应外部事件,如用户输入、设备状态变化等,同时也支持多任务操作系统中的进程调度和系统稳定性。

计算机系统中两种基本的事件处理机制

轮询和中断

轮询方式(Polling)

轮询是一种被动的事件处理机制,CPU不断地检查某个事件是否发生,如果发生了就进行处理。

优点:

  • 实现简单,不需要操作系统或硬件的额外支持。

缺点:

  • 效率低下,因为CPU在等待事件的过程中会做很多无用功。
  • 响应时间可能较长,因为CPU需要不断地检查,而不是在事件发生时立即响应。

中断方式(Interrupt)

中断是一种主动的事件处理机制,当某个设备或进程需要CPU注意时,它会发送一个信号(中断信号),CPU在接收到信号后会暂停当前的工作,转而去处理这个信号,处理完毕后再回到原来的地方继续执行。

优点:

  • 效率更高,CPU不需要不断地检查事件是否发生。
  • 响应时间快,因为CPU可以在事件发生的瞬间立即响应。

缺点:

  • 实现复杂,需要操作系统和硬件的支持。
  • 可能会影响系统的稳定性,如果中断处理不当,可能会导致系统崩溃。

中断处理需要注意的事项

快速响应:中断处理程序应该尽可能快地执行,以减少对其他程序执行的干扰。

保存和恢复现场:在进入中断处理程序之前,需要保存当前CPU的状态(包括程序计数器、寄存器等),这称为“保存现场”。中断处理完毕后,需要恢复这些状态,以便CPU能够回到中断发生前的状态继续执行,这称为“恢复现场”。

中断优先级:多个中断可能同时发生,需要根据中断的优先级来决定处理的顺序。

中断嵌套:如果一个中断处理程序正在执行时又发生了另一个中断,需要正确处理这种嵌套中断的情况。

资源共享:如果多个中断共享相同的资源,需要确保访问的同步,避免竞态条件。

错误处理:中断处理程序应该能够处理错误情况,确保系统稳定运行。

ARM核中断处理过程

.global _start_start:b resetldr pc,_undefined_instructionldr pc,_software_interrupt  @B   software_interruptldr pc,_prefetch_abortldr pc,_data_abortldr pc,_not_usedldr pc,_irqldr pc,_fiq
_undefined_instruction:.word _undefined_instruction
_software_interrupt:.word software_interrupt
_prefetch_abort:.word _prefetch_abort
_data_abort:.word _data_abort
_not_used:.word _not_used
_irq:.word irq
_fiq:.word _fiqreset:@告诉ARM核异常向量表所在的基地址adr r0,_start @获得异常向量表所在的地址mcr p15,0,r0,c12, c0, 0 @将异常向量表的基基地址写入cp15.c12ldr sp,=0x87800000bl  mainstop:b stopsoftware_interrupt:ldr sp,=0x81000000stmfd sp!,{r0-r12,lr}ldr r0,[lr,#-4]mov r1,#0xffbic r0,r0,r1,lsl #24ldmfd sp!,{r0-r12,pc}^irq:ldr sp,=0x82000000sub lr,lr,#4stmfd sp!,{r0-r12,lr}bl do_irqldmfd sp!,{r0-r12,pc}^

中断的基本概念:

中断源

中断源是指能够触发中断的事件或信号的来源。这些可以是硬件设备(如键盘、鼠标、网络接口卡等),也可以是软件事件(如程序执行特定的系统调用)。中断源是产生中断的“源头”。

中断号

中断号是系统对中断源的唯一标识符。在SOC(System on Chip,系统级芯片)中,芯片厂家会为内部的中断源分配一个编号,这个编号用于识别和区分不同的中断。当中断发生时,处理器会根据中断号来确定是哪一个中断源触发了中断,并调用相应的中断处理程序。

中断处理函数

中断处理函数(Interrupt Service Routine, ISR)是在中断发生后被调用的函数,用于处理中断。这个函数需要快速执行,以减少对系统其他部分的影响。

中断处理函数通常会完成以下任务:

  • 保存当前任务的状态。
  • 处理中断事件。
  • 恢复任务的状态。

中断控制器

中断控制器是硬件设备,用于管理中断信号。它负责以下任务:

  • 控制中断的优先级,决定哪些中断可以被立即处理,哪些需要等待。
  • 决定哪些中断是允许的,哪些是禁止的。
  • 处理多个中断源的中断请求,并将它们传递给处理器。

中断的两种基本类型:

内部中断

内部中断是由系统内部的事件或条件触发的中断。这些中断通常与系统的硬件或软件状态有关,不依赖于外部的物理信号。

  • GPT定时器:通用目的定时器(General-Purpose Timer)溢出时产生的中断,用于时间管理。
  • 看门狗定时器:当系统没有在规定时间内“喂狗”(即重置定时器),看门狗定时器会溢出并触发中断,用于系统监控。
  • 软件生成的中断:通过软件指令(如SWI或SVC)触发的中断,用于系统调用或异常处理。

外部中断

外部中断是由系统外部的物理信号触发的中断。这些中断依赖于外部设备或环境的变化,如按钮按下、传感器信号等。

  • 高电平触发:当外部管脚的电平达到高电平时触发中断。
  • 低电平触发:当外部管脚的电平达到低电平时触发中断。
  • 上升沿触发:当外部管脚的电平从低变高时触发中断。
  • 下降沿触发:当外部管脚的电平从高变低时触发中断。
  • 双边沿触发:无论电平是从低变高还是从高变低,都会触发中断。

这些触发方式可以根据具体的应用需求进行配置。例如,一个按钮可能被配置为在按下时(电平变化)触发中断,而一个通信接口可能在数据帧的开始(电平上升沿)触发中断。

外部中断通常需要外部中断控制器来管理,这个控制器会根据中断信号的优先级和状态,将中断请求发送给SOC的中断控制器,然后由中断控制器传递给处理器。

GIC通用中断控制器

GIC 全称是 Generic Interrupt Controller是 ARM 公司给 Cortex-A/R 内核提供的一个中断控制器,目前 GIC 有 4 个版本:V1~V4,V1 是最老的版本,已经被废弃了。GIC V2 是给 ARMv7-A 架构使用的,比如 Cortex-A7、Cortex-A9、Cortex-A15 等,V3 和 V4 是给 ARMv8-A/R 架构使用的,也就是 64 位芯 片使用的。

在Cortex-M 内核中,ARM设计了NVIC(Nested Vectored Interrupt Controller:内嵌向量中断控制器)中断控制器.

​​​​​​The Generic Interrupt Controller (GIC) architecture defines:(通用中断控制器(GIC)架构定义)

The GIC is a centralized resource for supporting and managing interrupts in a system that includes at least one processor. It provides:
GIC是一个集中的资源,用于支持和管理至少包含一个处理器的系统中的中断。它提供了:
• registers for managing interrupt sources, interrupt behavior, and interrupt routing to one or more processors
用于管理中断源、中断行为和中断路由到一个或多个处理器的寄存器
• support for:
— the ARM architecture Security Extensions
ARM架构安全扩展
— the ARM architecture Virtualization Extensions
ARM架构虚拟化扩展
— enabling, disabling, and generating processor interrupts from hardware (peripheral) interrupt sources
从硬件(外设)中断源启用、禁用和生成处理器中断
— Software-generated Interrupts (SGIs)
软件生成中断(SGIs)
— interrupt masking and prioritization
中断屏蔽和优先级
— uniprocessor and multiprocessor environments
单处理器和多处理器环境
— wakeup events in power-management environments.
电源管理环境中的唤醒事件

The GIC includes interrupt grouping functionality that supports:GIC包括支持的中断分组功能:

• configuring each interrupt as either Group 0 or Group 1
将每个中断配置为组0或组1
• signaling Group 0 interrupts to the target processor using either the IRQ or the FIQ exception request

信令组0中断到目标处理器使用IRQ或FIQ异常请求

• signaling Group 1 interrupts to the target processor using the IRQ exception request only
信令组1只使用IRQ异常请求中断到目标处理器
• a unified scheme for handling the priority of Group 0 and Group 1 interrupts
处理组0和组1中断优先级的统一方案
• optional lockdown of the configuration of some Group 0 interrupts.
可选锁定某些组0中断的配置

GIC的构成

GIC支持的中断类型

This is an interrupt asserted by a signal to the GIC. The GIC architecture defines the
following types of peripheral interrupt:
Peripheral interrupt This is an interrupt asserted by a signal to the GIC. The GIC architecture defines the following types of peripheral interrupt:
这是由信号向通用中断控制器(GIC)发起的中断请求。 GIC体系结构定义了下列外设中断类型。
Private Peripheral Interrupt (PPI)  私有外设中断
This is a peripheral interrupt that is specific to a single processor.指仅能被单个CPU核心识别和处理的中断类型,通常用于处理核心私有的或高优先级的中断。
Shared Peripheral Interrupt (SPI)  共享外设中断
This is a peripheral interrupt that the Distributor can route to any of a specified combination of processors.指可以被多个CPU核心识别和处理的中断类型,允许中断分发器根据配置将中断路由到一个或多个CPU核心。
Each peripheral interrupt is either:
每个外设中断可以是以下两种类型之一
边沿触发(Edge-triggered)
This is an interrupt that is asserted on detection of a rising edge of an interrupt signal and then, regardless of the state of the signal, remains asserted until it is cleared by the conditions defined by this specification.指的是中断信号的边沿变化(如从低到高)触发中断,一旦触发,即使信号继续维持在高电平,中断状态也会保持,直到通过特定的清除条件来重置。
电平敏感(Level-sensitive)
This is an interrupt that is asserted whenever the interrupt signal level is active, and deasserted whenever the level is not active.指的是中断信号的电平状态触发中断,如果信号电平保持在触发电平,中断就会持续有效,直到信号电平改变,不再满足触发条件。
tips:
当电平敏感型中断被断言时,其在GIC(通用中断控制器)中的状态为挂起(pending),或者活动且挂起。如果外设由于任何原因取消断言(deasserts)中断信号,GIC将从中断中移除挂起状态。

Software-generated interrupt (SGI) 软件生成中断
This is an interrupt generated by software writing to a GICD_SGIR register in the GIC. The 
system uses SGIs for interprocessor communication.
An SGI has edge-triggered properties. The software triggering of the interrupt is equivalent 
to the edge transition of the interrupt request signal.

When an SGI occurs in a multiprocessor implementation, the CPUID field in the Interrupt
Acknowledge Register, GICC_IAR , or the Aliased Interrupt Acknowledge Register,
GICC_AIAR , identifies the processor that requested the interrupt.

In an implementation that includes the GIC Virtualization Extensions:
• when an SGI occurs, management registers in the GIC virtualization Extensions enable the requesting processor to be reported to the Guest OS, as required by the GIC specifications
• by writing to the management registers in the GIC Virtualization Extensions, a hypervisor can generate a virtual interrupt that appears to a virtual machine as an SGI.
See Software-generated interrupts on page 5-165 and List Registers, GICH_LRn on page 5-176 for more information.

  • 这是通过软件向GIC的GICD_SGIR寄存器写入数据来生成的中断。系统使用SGI进行处理器间通信。
  • SGI具有边沿触发特性。软件触发中断相当于中断请求信号的边沿转换。
  • 在多处理器实现中,当发生SGI时,中断确认寄存器(Interrupt Acknowledge Register,GICC_IAR)或别名中断确认寄存器(Aliased Interrupt Acknowledge Register,GICC_AIAR)中的CPUID字段标识请求中断的处理器。
  • 在包含GIC虚拟化扩展的实现中:
    • 当发生SGI时,GIC虚拟化扩展的管理寄存器允许根据GIC规范向客户操作系统(Guest OS)报告请求处理器。
    • 通过向GIC虚拟化扩展的管理寄存器写入数据,虚拟机监控器(hypervisor)可以生成一个虚拟中断,该中断对虚拟机表现为SGI。

Virtual interrupt:虚拟中断

In a GIC that implements the GIC Virtualization Extensions, an interrupt that targets a 
virtual machine running on a processor, and is typically signaled to the processor by the 
connected virtual CPU interface.

在实现了GIC虚拟化扩展的GIC(通用中断控制器)中,针对在处理器上运行的虚拟机的中断,通常由连接的虚拟CPU接口向处理器发出信号。这种中断被称为虚拟中断。


Maintenance interrupt :维护中断:
In a GIC that implements the GIC Virtualization Extensions, a level-sensitive interrupt that 
is used to signal key events, such as a particular group of interrupts becoming enabled or 
disabled. 

在实现了GIC虚拟化扩展的GIC(通用中断控制器)中,一种电平敏感的中断被用来信号关键事件,例如特定组的中断被启用或禁用。

GIC支持的中断源个数

The GIC assigns interrupt ID numbers ID0-ID1019 as follows:GIC分配的中断ID号ID0-ID1019如下所示

• Interrupt numbers ID32-ID1019 are used for SPIs.

中断编号ID32至ID1019用于SPI(Shared Peripheral Interrupts,共享外设中断)

• Interrupt numbers ID0-ID31 are used for interrupts that are private to a CPU interface. These interrupts are banked in the Distributor.

中断编号ID0至ID31用于特定于CPU接口的私有中断。这些中断在中断分发器(Distributor)中是分组的(banked)。

A banked interrupt is one where the Distributor can have multiple interrupts with the same ID. A banked interrupt is identified uniquely by its ID number and its associated CPU interface number.

分组中断(Banked Interrupt)是指中断分发器可以拥有多个具有相同ID的中断。分组中断通过其ID编号和相关的CPU接口编号唯一标识。

Of the banked interrupt IDs:
— ID0-ID15 are used for SGIs

ID0至ID15用于SGI(Software Generated Interrupts,软件生成中断)

— ID16-ID31 are used for PPIs

ID16至ID31用于PPI(Private Peripheral Interrupts,私有外设中断)

Distributor(中断分发器)

The Distributor centralizes all interrupt sources, determines the priority of each interrupt, and for each CPU interface forwards the interrupt with the highest priority to the interface, for priority masking and preemption handling.中断分发器(Distributor)集中管理所有中断源,确定每个中断的优先级,并且对于每个CPU接口,将最高优先级的中断转发到该接口,以进行优先级掩蔽(priority masking)和抢占处理(preemption handling)。
  • 优先级掩蔽(Priority Masking):一种机制,允许CPU忽略低于特定优先级阈值的中断,从而确保高优先级任务能够获得及时处理。
  • 抢占处理(Preemption Handling):当一个高优先级的中断到来时,如果CPU正在处理一个低优先级的中断或任务,系统会暂停当前任务,转而处理高优先级中断,处理完成后再返回执行被暂停的任务。

The Distributor provides a programming interface for:

分发器为以下方面提供了编程接口:

• Globally enabling the forwarding of interrupts to the CPU interfaces.
全局使能将中断转发到CPU接口
• Enabling or disabling each interrupt.
启用或禁用每个中断
• Setting the priority level of each interrupt.
设置每个中断的优先级
• Setting the target processor list of each interrupt.
•设置每个中断的目标处理器列表。
• Setting each peripheral interrupt to be level-sensitive or edge-triggered.
将每个外设中断设置为电平敏感或边缘触发
• Setting each interrupt as either Group 0 or Group 1.
设置组0或组1

CPU interface block(CPU接口单元)

Each CPU interface block provides the interface for a processor that is connected to the GIC. Each CPU interface provides a programming interface for(每个CPU接口块都为连接到GIC的处理器提 供接口。每个CPU接口都为以下方面提供编程接口):
• enabling the signaling of interrupt requests to the processor
允许中断请求信号被发送到处理器
• acknowledging an interrupt
确认中断
• indicating completion of the processing of an interrupt
指示中断处理完成
处理器完成中断服务程序(ISR)的执行后,通过发送结束中断(End of Interrupt,EOI)信号来指示中断处理已经完成。
• setting an interrupt priority mask for the processor
设置处理器的中断优先级掩蔽
为处理器设置一个优先级阈值,只有优先级高于或等于这个阈值的中断才会被处理器识别和处理。
• defining the preemption policy for the processor
定义处理器的抢占策略
设置处理器如何处理高优先级中断与当前正在处理的低优先级中断之间的关系,即决定是否允许高优先级中断打断低优先级中断的处理。
• determining the highest priority pending interrupt for the processor.
确定处理器最高优先级的挂起中断
识别和确定当前挂起(待处理)的中断中,优先级最高的中断,以便处理器可以优先处理。

中断分组(Interrupt grouping)

• configuring each interrupt as either Group 0 or Group 1
配置每个中断为组0(Group 0)或组1(Group 1)
• signaling Group 0 interrupts to the target processor using either the IRQ or the FIQ exception request
使用IRQ或FIQ异常请求向目标处理器发送组0中断
• signaling Group 1 interrupts to the target processor using the IRQ exception request only
仅使用IRQ异常请求向目标处理器发送组1中断
• a unified scheme for handling the priority of Group 0 and Group 1 interrupts
统一的方案来处理组0和组1中断的优先级
• optional lockdown of the configuration of some Group 0 interrupts.
可选的锁定一些组0中断的配置
Group 0 interrupts are Secure interrupts (第0组的中断都是安全中断)
Group 1 interrupts are Non-secure interrupts (第1组的中断都是非安全中断)
By default, all interrupts are Group 0 interrupts, and are signaled to a connected processor using the IRQ interrupt request。
(默认情况下所有中断都在第0组,产生的中断的信号使用IRQ向处理器发出中断请求)
each interrupt can be configured as Group 1 interrupt, or as a Group 0 interrupt
(每个中断都可以配置为第1组中断或第0组中断)
a CPU interface can be configured to signal Group 0 interrupts to a connected processor
using the FIQ interrupt request.
(CPU接口可以配置为使用FIQ中断请求向连接的处理器发出组0中断信号

中断优先级(Interrupt prioritization)

Software configures interrupt prioritization in the GIC by assigning a priority value to each
interrupt source. Priority values are 8-bit unsigned binary. A GIC supports a minimum of 16 and a maximum of 256 priority levels.
(可以通过软件为每个中断源分配优先级值来配置GIC中的中断优先级。优先级值是8位无符号二进制。GIC支持最小16个和最大256个优先级。)
In the GIC prioritization scheme, lower numbers have higher priority, that is, the lower the
assigned priority value the higher the priority of the interrupt . Priority field value 0 always
indicates the highest possible interrupt priority, and the lowest priority value depends on the
number of implemented priority levels。(在GIC优先级设计方案中, 较低的数字具有较高的优先级,即分配的优先级值越低,中断的优先级越高。优先级字段值0总是表示可能的最高中断优先级,而最低优先级值取决于实现的优先级级别的数量)
Priority masking (优先级屏蔽)
The GICC_PMR for a CPU interface defines a priority threshold for the target processor. The GIC only signals pending interrupts with a higher priority than this threshold value to the target processor . A value of zero, the register reset value, masks all interrupts from being signaled to the associated processor. (CPU接口单元的GICC_PMR定义了目标处理器的优先级阈(yu)值。GIC只向目标处理器发出优先级高于该阈值的挂起中断的信号。零值,即寄存器重置值,屏蔽了所有被发信号通知相关处理器的中断)

中断状态(interrupt states)

Inactive(不活动)

An interrupt that is not active (非活动的中断)

Pending(待定)

An interrupt from a source to the GIC that is recognized as asserted in hardware, or generated by software, and is waiting to be serviced by a target processor.

(硬件设备产生 或 由软件生成一个中断到达GIC,并等待由目标处理器处理)

Active (活跃)

An interrupt from a source to the GIC that has been acknowledged by a processor, and is

being serviced but has not completed.

(一个中断到达GIC,已被处理器确认,并且是正在处理但尚未完成)

Active and pending(活动和待定)

A processor is servicing the interrupt and the GIC has a pending interrupt from the

same source.(处理器正在处理中断这个中断源,并且来了一个同类的中断源处于待定状态)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/10638.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

4-图像梯度计算

文章目录 4.图像梯度计算(1)Sobel算子(2)梯度计算方法(3)Scharr与Laplacian算子4.图像梯度计算 (1)Sobel算子 图像梯度-Sobel算子 Sobel算子是一种经典的图像边缘检测算子,广泛应用于图像处理和计算机视觉领域。以下是关于Sobel算子的详细介绍: 基本原理 Sobel算子…

苍穹外卖——数据统计

在商家管理端的左侧,有一个名为"数据统计"的菜单,该页面负责展示各个维度的数据统计,分别是营业额统计、用户统计、订单统计、销量排名top10。统计的数据是借助一些图形化的报表技术来生成并展示的。在左上角还可选择时间段&#x…

优盘恢复原始容量工具

买到一个优盘,显示32mb,我见过扩容盘,但是这次见到的是缩容盘,把2g的容量缩成32MB了,首次见到。。用芯片查询工具显示如下 ChipsBank(芯邦) CBM2199E 使用以下工具,恢复原始容量。。 其他CMB工具可能不行…

Flutter Candies 一桶天下

| | | | | | | | 入魔的冬瓜 最近刚入桶的兄弟,有责任心的开发者,对自己的项目会不断进行优化,达到最完美的状态 自定义日历组件 主要功能 支持公历,农历,节气,传统节日,常用节假日 …

[Collection与数据结构] B树与B+树

🌸个人主页:https://blog.csdn.net/2301_80050796?spm1000.2115.3001.5343 🏵️热门专栏: 🧊 Java基本语法(97平均质量分)https://blog.csdn.net/2301_80050796/category_12615970.html?spm1001.2014.3001.5482 🍕 Collection与…

ROS应用之SwarmSim在ROS 中的协同路径规划

SwarmSim 在 ROS 中的协同路径规划 前言 在多机器人系统(Multi-Robot Systems, MRS)中,SwarmSim 是一个常用的模拟工具,可以对多机器人进行仿真以实现复杂任务的协同。除了任务分配逻辑以外,SwarmSim 在协同路径规划方…

新鲜速递:DeepSeek-R1开源大模型本地部署实战—Ollama + MaxKB 搭建RAG检索增强生成应用

在AI技术快速发展的今天,开源大模型的本地化部署正在成为开发者们的热门实践方向。最火的莫过于吊打OpenAI过亿成本的纯国产DeepSeek开源大模型,就在刚刚,凭一己之力让英伟达大跌18%,纳斯达克大跌3.7%,足足是给中国AI产…

【Rust自学】15.5. Rc<T>:引用计数智能指针与共享所有权

喜欢的话别忘了点赞、收藏加关注哦&#xff0c;对接下来的教程有兴趣的可以关注专栏。谢谢喵&#xff01;(&#xff65;ω&#xff65;) 15.5.1. 什么是Rc<T> 所有权在大部分情况下都是清晰的。对于一个给定的值&#xff0c;程序员可以准确地推断出哪个变量拥有它。 …

UE5制作视差图

双目深度估计开源数据集很多都是用UE制作的&#xff0c;那么我们自己能否通过UE制作自己想要的场景的数据集呢。最近花了点时间研究了一下&#xff0c;分享给需要的小伙伴。 主要使用的是UnrealCV插件&#xff0c;UnrealCV是一个开源项目&#xff0c;旨在帮助计算机视觉研究人…

基于遗传优化GRNN和Hog特征提取的交通标志识别算法matlab仿真

目录 1.算法运行效果图预览 2.算法运行软件版本 3.部分核心程序 4.算法理论概述 4.1 HOG 4.2 GRNN&#xff08;General Regression Neural Network&#xff09;模型原理 4.3 遗传算法&#xff08;GA&#xff09;优化GRNN平滑因子 5.算法完整程序工程 1.算法运行效果图预…

C语言【基础篇】之流程控制——掌握三大结构的奥秘

流程控制 &#x1f680;前言&#x1f99c;顺序结构&#x1f4af; 定义&#x1f4af;执行规则 &#x1f31f;选择结构&#x1f4af;if语句&#x1f4af;switch语句&#x1f4af;case穿透规则 &#x1f914;循环结构&#x1f4af;for循环&#x1f4af;while循环&#x1f4af;do -…

C++实现状态模式

首先上代码&#xff1a; #include <iostream> #include <memory>class Context;class State { public:virtual void Handle(Context * context) 0; //纯虚函数virtual ~State() default; //虚析构函数 };//创建状态A class ConcreateStateA : public State{…

【React】PureComponent 和 Component 的区别

前言 在 React 中&#xff0c;PureComponent 和 Component 都是用于创建组件的基类&#xff0c;但它们有一个主要的区别&#xff1a;PureComponent 会给类组件默认加一个shouldComponentUpdate周期函数。在此周期函数中&#xff0c;它对props 和 state (新老的属性/状态)会做一…

二级C语言:二维数组每行最大值与首元素交换、删除结构体的重复项、取出单词首字母

目录 一、程序填空 --- 二维数组每行最大值与首元素交换 题目 分析 知识点 --- 交换语句 二、程序修改 --- 删除结构体的重复项 题目 分析 三、程序设计 --- 取出单词首字母 题目 分析 前言 本章讲解&#xff1a;二维数组每行最大值与首元素交换、删除结构体的重复项…

CUDA学习-内存访问

一 访存合并 1.1 说明 本部分内容主要参考: 搞懂 CUDA Shared Memory 上的 bank conflicts 和向量化指令(LDS.128 / float4)的访存特点 - 知乎 1.2 share memory结构 图1.1 share memory结构 放在 shared memory 中的数据是以 4 bytes(即 32 bits)作为 1 个 word,依…

【python】python基于机器学习与数据分析的手机特性关联与分类预测(源码+数据集)【独一无二】

&#x1f449;博__主&#x1f448;&#xff1a;米码收割机 &#x1f449;技__能&#x1f448;&#xff1a;C/Python语言 &#x1f449;专__注&#x1f448;&#xff1a;专注主流机器人、人工智能等相关领域的开发、测试技术。 python基于机器学习与数据分析的手机特性关联与分类…

【leetcode详解】T3175(一点反思)

解题心得 要写出一个好的程序&#xff0c;有效解决问题&#xff0c;思路上就不能“太乖” —— 不能被题目的叙述过程所束缚&#xff0c;而是力求细思问题&#xff0c;抽象化问题&#xff0c;并找到背后的逻辑&#xff1b;最后抓住核心对象&#xff0c;去除多余项&#xff0c;…

图论——最小生成树

最小生成树 给定一个无向图&#xff0c;在图中选择若干条边把图的所有节点连起来。要求边长之和最小。在图论中&#xff0c;叫做求最小生成树。 prim算法 prim 算法采用的是一种贪心的策略。 每次将离连通部分的最近的点和点对应的边加入的连通部分&#xff0c;连通部分逐渐扩大…

jvisualvm工具使用

jvisualvm 是JDK自带的具有图形界面操作功能的JVM性能监控和诊断工具&#xff0c;它不仅能分析和诊断堆转储文件&#xff0c;在线实时监控本地JVM进程&#xff0c;还能监控远程服务器上的JVM进程。 1 分析服务器下载dump文件 1&#xff09;在我们在安装JDK的bin目录双击jvisa…

C++ list

list需知&#xff1a; list不会出现insert迭代器失效问题 链表插入不会影响原有数据相对位置&#xff0c;且不用扩容 但是erase会导致相对数据位置移动&#xff0c;所有其erase会导致迭代器失效 list排序效率很低 不建议使用 小规模数据量可以使用&#xff0c;比较方便 此外…