Exemple #1
0
        public Task(ID TaskID, ref T_CTSK pk_ctsk, Nucleus pNucleus)
        {
            StaCD    = null;
            m_TaskID = TaskID;

            m_ctsk         = pk_ctsk;
            m_rtsk.exinf   = m_ctsk.exinf;
            m_rtsk.tskpri  = m_ctsk.itskpri;
            m_rtsk.tskstat = TSKSTAT.TTS_DMT;

            m_Nucleus = pNucleus;

            m_CPUContext  = m_Nucleus.NewCPUContext();
            m_ReleaseWait = false;
        }
Exemple #2
0
        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);
        }