public ER cre_tsk(ID tskid, ref T_CTSK pk_ctsk, out ID p_takid) { ER Result = ER.E_NOEXS; p_takid = ID.NULL; if (g_Kernel == null) return ER.E_DLT; g_Kernel.LockCPU(); try { Result = g_Kernel.Nucleus.CreateTask(tskid, ref pk_ctsk, out p_takid); } finally { g_Kernel.UnlockCPU(); } return Result; }
public ER CreateTask(ID tskid, ref T_CTSK pk_ctsk, out ID p_takid) { int i; Task Task; //if(pk_ctsk == null) // return ER.E_PAR; if (tskid == ID.ID_AUTO) { //if (p_takid == null) // return ER.E_PAR; tskid.Value = 1; for (i = 0; ; i++) { if (i >= m_TaskTable.Count) { Task = new Task(tskid, ref pk_ctsk, this); m_TaskTable.Add(Task); Task.Prepare(); break; } if (tskid == m_TaskTable[i].TaskID) { tskid.Value++; } else { Task = new Task(tskid, ref pk_ctsk, this); m_TaskTable.Insert(i, Task); Task.Prepare(); break; } } p_takid = tskid; } else { ID tmpid; p_takid = ID.NULL; for (i = 0; i < m_TaskTable.Count; i++) { tmpid = m_TaskTable[i].TaskID; if (tskid == tmpid) { return ER.E_OBJ; } else if (tskid < tmpid) { break; } } Task = new Task(tskid, ref pk_ctsk, this); m_TaskTable.Insert(i, Task); Task.Prepare(); } return ER.E_OK; }