Asserted、Deasserted的理解

本文解释了Asserted(Asserting、Assert)与Deasserted(Deassert、deasserting、de-asserted)的概念,Asserted意味着将信号变为有效状态,有效电平可以是高电平或低电平;而Deasserted则是解除有效状态。
Asserted(Asserting、Assert),Deasserted (Deassert、deasserting、de-asserted)

asserted的意思就是把信号变为active(可以理解为有效),根据系统有求不同,该有效电平可以是高电平(即高有效)也可以是低电平(即低有效)。

deasserted的意思就是解除active状态,就是信号变为非active状态,可以是高也可以是低。

root@prigz-k8s-bgp-yiduncpuyw87:~# ipmitool sel elist 1 | 01/17/2025 | 17:54:04 | Event Logging Disabled Event_log | Log area reset/cleared | Asserted 2 | 02/21/2025 | 17:10:29 | System ACPI Power State ACPI_state | S5/G2: soft-off | Asserted 3 | 02/21/2025 | 17:13:28 | System ACPI Power State ACPI_state | S0/G0: working | Asserted 4 | 02/21/2025 | 17:13:28 | Processor CPU0_Status | Presence detected | Asserted 5 | 02/21/2025 | 17:13:28 | Processor CPU1_Status | Presence detected | Asserted 6 | 02/21/2025 | 17:13:29 | Power Supply PSU1_Status | Presence detected | Asserted 7 | 02/21/2025 | 17:13:29 | Power Supply PSU2_Status | Presence detected | Asserted 8 | 02/21/2025 | 17:13:29 | Microcontroller BMC_Start | Device Enabled | Asserted 9 | 02/21/2025 | 17:13:48 | Add-in Card OCP_Card1_Sta | Device Absent | Asserted a | 02/21/2025 | 17:13:48 | Add-in Card OCP_Card2_Sta | Device Absent | Asserted b | 02/21/2025 | 17:14:12 | System Event #0xf7 | Timestamp Clock Sync | Asserted c | 02/21/2025 | 17:14:16 | Memory DIMM2 | Presence Detected | Asserted d | 02/21/2025 | 17:14:16 | Memory DIMM6 | Presence Detected | Asserted e | 02/21/2025 | 17:14:16 | Memory DIMM9 | Presence Detected | Asserted f | 02/21/2025 | 17:14:16 | Memory DIMM13 | Presence Detected | Asserted 10 | 02/21/2025 | 17:14:16 | Memory DIMM18 | Presence Detected | Asserted 11 | 02/21/2025 | 17:14:16 | Memory DIMM22 | Presence Detected | Asserted 12 | 02/21/2025 | 17:14:16 | Memory DIMM25 | Presence Detected | Asserted 13 | 02/21/2025 | 17:14:16 | Memory DIMM29 | Presence Detected | Asserted 14 | 02/21/2025 | 17:14:16 | Drive Slot / Bay Disk0 | Drive Present | Asserted 15 | 02/21/2025 | 17:16:34 | System ACPI Power State ACPI_state | S5/G2: soft-off | Asserted 16 | 02/21/2025 | 17:16:39 | System ACPI Power State ACPI_state | S0/G0: working | Asserted 17 | 02/21/2025 | 17:17:25 | System Boot Initiated RestartInitiated | Initiated by warm reset | Asserted 18 | 02/21/2025 | 17:19:44 | System Event #0xf7 | Timestamp Clock Sync | Asserted 19 | 02/21/2025 | 17:22:26 | OS Boot | boot completed - device not specified | Asserted root@prigz-k8s-bgp-yiduncpuyw87:~# ^C
03-27
### 断言(Assert)在编程中的应用 断言是一种用于调试程序的技术,在开发过程中用来验证假设条件是否成立。当断言失败时,通常会抛出异常并终止程序运行,这有助于开发者快速定位错误位置。 #### Python 中的 `assert` 关键字 在 Python 编程语言中,可以通过内置的关键字 `assert` 来实现断言功能。其基本语法如下: ```python assert condition, message ``` 这里 `condition` 是一个布尔表达式,如果该表达式的计算结果为假,则触发 AssertionError 异常,并显示指定的消息 `message`[^1]。 #### 使用示例 下面是一个简单的例子展示如何利用 `assert` 进行测试: ```python def divide(a, b): assert b != 0, "除数不能为零" return a / b print(divide(10, 2)) # 正确情况下的输出 print(divide(10, 0)) # 将引发 AssertionError 错误 ``` 在这个案例里,函数内部设置了前置条件检查——即确保分母不等于零。一旦违反此规则就会立即停止执行并向用户提供提示信息。 #### 处理 AssertError 的方法 对于由断言引起的错误处理方式有两种主要途径: - **捕获异常**:可以在适当的位置使用 try-except 结构来捕捉可能出现的 AssertionError 并采取相应措施; - **禁用断言**:通过命令行参数 `-O` 或者修改编译选项使得最终发布的版本忽略所有的断言语句而不影响性能表现。 需要注意的是,虽然断言是非常有用的工具,但在生产环境中应当谨慎启用它们以免造成不必要的开销或者安全风险。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值