void OSSemPend (OS_EVENT *pevent, INT16U timeout, INT8U *err)
{
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr
#endif
if (OSIntNesting >0) { /* See if called from ISR ...*/
*err = OS_ERR_PEND_ISR /* ... can't PEND from an ISR*/
return
}
#if OS_ARG_CHK_EN >0
if (pevent == (OS_EVENT *)0) {/* Validate 'pevent' */
*err = OS_ERR_PEVENT_NULL
return
}
if (pevent->OSEventType != OS_EVENT_TYPE_SEM) { /* Validate event block type */
*err = OS_ERR_EVENT_TYPE
return
}
#endif
OS_ENTER_CRITICAL()
if (pevent->OSEventCnt >0) { /* If sem. is positive, resource available ... */
pevent->OSEventCnt--/* ... decrement semaphore only if positive. */
OS_EXIT_CRITICAL()
*err = OS_NO_ERR
return
}
/* Otherwise, must wait until event occurs */
OSTCBCur->OSTCBStat |= OS_STAT_SEM /* Resource not available, pend on semaphore */
OSTCBCur->OSTCBDly = timeout /* Store pend timeout in TCB */
OS_EventTaskWait(pevent)/* Suspend task until event or timeout occurs*/
OS_EXIT_CRITICAL()
OS_Sched() /* Find next highest priority task ready */
OS_ENTER_CRITICAL()
if (OSTCBCur->OSTCBStat &OS_STAT_SEM) { /* Must have timed out if still waiting for event*/
OS_EventTO(pevent)
OS_EXIT_CRITICAL()
*err = OS_TIMEOUT /* Indicate that didn't get event within TO */
return
}
OSTCBCur->OSTCBEventPtr = (OS_EVENT *)0
OS_EXIT_CRITICAL()
*err = OS_NO_ERR
}
开源安全事件元数据(OSSEM)是一个社区主导的项目,主要关注来自不同数据源和操作系统的安全事件日志的文档化和标准化。安全事件以字典格式记录下来,可以作为诸如ThreatHunter-Playbook之类项目的参考,同时将数据源映射到用于验证对抗性技术检测的数据分析。此外,该项目还提供了一个公共信息模型(CIM),可以在数据规范化过程中供数据工程师使用,从而允许安全分析人员跨不同数据源查询和分析数据。最后,该项目还提供了关于特定数据源中确定的结构和关系的文档,以促进数据分析的开发。任务2输出5之后,由于等待信号量被挂起,之后任务1输出3,然后发信号量,注意发信号亮并不是简单的+1,OSSemPost中有这几行代码if(pevent->OSEventGrp!=0){(void)OS_EventTaskRdy(pevent,(void*)0,OS_STAT_SEM,OS_STAT_PEND_OK)OS_EXIT_CRITICAL()OS_Sched()return(OS_ERR_NONE)}此时因为任务2的优先级较1低,所以没有立即运行,而是任务1继续输出4、0然后挂起自己,任务2就运行了,输出678欢迎分享,转载请注明来源:夏雨云
评论列表(0条)