public ER ClearEventFlag(FLGPTN setptn) { if (setptn.Value == 0) { return(ER.E_PAR); } m_FlagPattern &= ~setptn; for (LinkedListNode <Task> node = m_TskQueue.First; node != null; node = node.Next) { Task task = node.Value; if (CheckPattern(task.WaitPattern, task.WaitMode)) { m_TskQueue.Remove(node); if (!task.ReleaseWait()) { return(ER.E_RLWAI); } } } return(ER.E_OK); }
private bool CheckPattern(FLGPTN waiptn, MODE wfmode) { if ((wfmode & MODE.TWF_ORW) != 0) { return((m_FlagPattern & waiptn) != 0); } else { return((m_FlagPattern & waiptn) == waiptn); } }
public ER WaitEventFlag(ref FLGPTN p_flgptn, TMO tmout, FLGPTN waiptn, MODE wfmode) { ER ret; Task task = m_Nucleus.GetTask(ID.TSK_SELF); if ((tmout != 0) && (task == null)) { return(ER.E_CTX); } //if (p_flgptn == null) // return ER.E_PAR; if ((wfmode & ~(MODE.TWF_ANDW | MODE.TWF_ORW | MODE.TWF_CLR)) != 0) { return(ER.E_PAR); } if ((m_TskQueue.First == null) && CheckPattern(waiptn, wfmode)) { p_flgptn = m_FlagPattern; if ((wfmode & MODE.TWF_CLR) != 0) { m_FlagPattern = 0; } } else { if (task == null) { return(ER.E_TMOUT); } if (tmout == 0) { return(ER.E_TMOUT); } task.WaitPattern = waiptn; task.WaitMode = wfmode; ret = task.Wait(m_TskQueue, TSKWAIT.TTW_FLG, m_FlgID, tmout); switch (ret) { case ER.E_OK: p_flgptn = m_FlagPattern; if (!CheckPattern(waiptn, wfmode)) { return(ER.E_RLWAI); } if ((wfmode & MODE.TWF_CLR) != 0) { m_FlagPattern = 0; } break; case ER.E_TMOUT: return(ER.E_TMOUT); default: return(ER.E_RLWAI); } } return(ER.E_OK); }
public ER clr_flg(ID flgid, FLGPTN clrptn) { ER Result = ER.E_NOEXS; EventFlag EventFlag; if (g_Kernel == null) return ER.E_DLT; g_Kernel.LockCPU(); try { EventFlag = g_Kernel.Nucleus.GetEventFlag(flgid); if (EventFlag == null) Result = ER.E_NOEXS; else Result = EventFlag.ClearEventFlag(clrptn); } finally { g_Kernel.UnlockCPU(); } return Result; }
public ER wai_flg(ref FLGPTN p_flgptn, ID flgid, FLGPTN waiptn, MODE wfmode) { ER Result = ER.E_NOEXS; EventFlag EventFlag; if (g_Kernel == null) return ER.E_DLT; g_Kernel.LockCPU(); try { EventFlag = g_Kernel.Nucleus.GetEventFlag(flgid); if (EventFlag == null) Result = ER.E_NOEXS; else Result = EventFlag.WaitEventFlag(ref p_flgptn, TMO.TMO_FEVR, waiptn, wfmode); } finally { g_Kernel.UnlockCPU(); } return Result; }
private bool CheckPattern(FLGPTN waiptn, MODE wfmode) { if ((wfmode & MODE.TWF_ORW) != 0) return (m_FlagPattern & waiptn) != 0; else return (m_FlagPattern & waiptn) == waiptn; }
public ER WaitEventFlag(ref FLGPTN p_flgptn, TMO tmout, FLGPTN waiptn, MODE wfmode) { ER ret; Task task = m_Nucleus.GetTask(ID.TSK_SELF); if ((tmout != 0) && (task == null)) return ER.E_CTX; //if (p_flgptn == null) // return ER.E_PAR; if ((wfmode & ~(MODE.TWF_ANDW | MODE.TWF_ORW | MODE.TWF_CLR)) != 0) return ER.E_PAR; if ((m_TskQueue.First == null) && CheckPattern(waiptn, wfmode)) { p_flgptn = m_FlagPattern; if ((wfmode & MODE.TWF_CLR) != 0) m_FlagPattern = 0; } else { if (task == null) return ER.E_TMOUT; if (tmout == 0) return ER.E_TMOUT; task.WaitPattern = waiptn; task.WaitMode = wfmode; ret = task.Wait(m_TskQueue, TSKWAIT.TTW_FLG, m_FlgID, tmout); switch (ret) { case ER.E_OK: p_flgptn = m_FlagPattern; if (!CheckPattern(waiptn, wfmode)) return ER.E_RLWAI; if ((wfmode & MODE.TWF_CLR) != 0) m_FlagPattern = 0; break; case ER.E_TMOUT: return ER.E_TMOUT; default: return ER.E_RLWAI; } } return ER.E_OK; }
public ER SetEventFlag(FLGPTN setptn) { if (setptn.Value == 0) return ER.E_PAR; m_FlagPattern |= setptn; for (LinkedListNode<Task> node = m_TskQueue.First; node != null; node = node.Next) { Task task = node.Value; if (CheckPattern(task.WaitPattern, task.WaitMode)) { m_TskQueue.Remove(node); if (!task.ReleaseWait()) return ER.E_RLWAI; } } return ER.E_OK; }