EXPORT StatusType osekSetEvent ( TaskType TaskID , EventMaskType Mask ) #endif { StatusType ercd = E_OK; uint8 flgid ; OS_EXT_VALIDATE((TaskID < cfgOS_TASK_NUM),E_OS_ID); flgid = knl_tcb_flgid[TaskID]; OS_EXT_VALIDATE((flgid != INVALID_FLAG),E_OS_ACCESS); OS_EXT_VALIDATE((SUSPENDED != knl_tcb_state[TaskID]),E_OS_STATE); BEGIN_CRITICAL_SECTION(); knl_fcb_set[flgid] |= Mask; if((knl_fcb_set[flgid] & knl_fcb_wait[flgid]) != NO_EVENT) { knl_fcb_wait[flgid] = NO_EVENT; knl_tcb_state[TaskID] = READY; knl_make_runnable(TaskID); } END_CRITICAL_SECTION(); OS_VALIDATE_ERROR_EXIT() OsErrorProcess2(SetEvent,tskid,TaskID,mask,Mask); return ercd; }
/* |------------------+----------------------------------------------------------| */ StatusType SetEvent ( TaskType TaskID , EventMaskType Mask ) { StatusType ercd = E_OK; ID flgid; FLGCB *flgcb; TCB *tcb; OS_CHECK_EXT((TaskID < cfgOSEK_TASK_NUM),E_OS_ID); flgid = knl_gtsk_table[TaskID].flgid; OS_CHECK_EXT((flgid != INVALID_EVENT),E_OS_ACCESS); tcb = &knl_tcb_table[TaskID]; OS_CHECK_EXT(((tcb->state & (TS_READY | TS_WAIT)) != 0),E_OS_STATE); flgcb = &knl_flgcb_table[flgid]; BEGIN_CRITICAL_SECTION; flgcb->flgptn |= Mask; if((flgcb->flgptn & flgcb->waipth) != NO_EVENT) { flgcb->waipth = NO_EVENT; tcb->state = TS_READY; knl_make_runnable(tcb); } END_CRITICAL_SECTION; Error_Exit: #if(cfgOS_ERROR_HOOK == STD_ON) if(E_OK != ercd) { BEGIN_CRITICAL_SECTION; _errorhook_svcid = OSServiceId_SetEvent; _errorhook_par1.tskid = TaskID; _errorhook_par2.mask = Mask; CallErrorHook(ercd); END_CRITICAL_SECTION; } #endif /* cfgOS_ERROR_HOOK */ return ercd; }