Exemplo n.º 1
0
 public CyclicHandler(HNO cycno, ref T_DCYC pk_dcyc, Nucleus pNucleus)
 {
     m_CycNo = cycno;
     m_dcyc = pk_dcyc;
     m_Count = pk_dcyc.cyctim;
     m_Nucleus = pNucleus;
 }
Exemplo n.º 2
0
 public Semaphore(ID semid, ref T_CSEM pk_csem, Nucleus pNucleus)
 {
     m_SemID = semid;
     m_csem = pk_csem;
     m_Count = pk_csem.isemcnt;
     m_Nucleus = pNucleus;
 }
Exemplo n.º 3
0
        public MemoryPoolFixedsize(ID mpfid, ref T_CMPF pk_cmpf, Nucleus pNucleus)
        {
            pointer Block;

            m_MpfID = mpfid;
            m_cmpf = pk_cmpf;
            m_Nucleus = pNucleus;

            for (int i = 0; i < pk_cmpf.blkcnt; i++) {
                Block = new pointer(pk_cmpf.addr, i * pk_cmpf.blksz);
                pointer.memset(Block, 0, pk_cmpf.blksz);
                m_MpfQueue.AddLast(Block);
            }
        }
Exemplo n.º 4
0
        public MemoryPool(ID mplid, ref T_CMPL pk_cmpl, Nucleus pNucleus)
        {
            TMemNode Block = new TMemNode(pk_cmpl.addr, pk_cmpl.mplsz);

            m_MplID = mplid;
            m_cmpl = pk_cmpl;
            m_Nucleus = pNucleus;
            m_MaxSize = pk_cmpl.mplsz;
            m_FreeSize = pk_cmpl.mplsz;

            m_FreeMem.AddLast(Block);
            #if DEBUG
            m_pFirstBlock = null;
            m_pLastBlock = null;
            m_nBlockCount = 0;
            m_Dumped = false;
            #endif
        }
Exemplo n.º 5
0
        public Kernel(long frequency, int sysTmrIntNo, TMO sysTmrIntv)
        {
            m_Nucleus = new Nucleus(this, sysTmrIntNo, sysTmrIntv);

            m_Frequency = frequency;
            m_OnSetEvent = null;
            m_OnStart = null;
            m_OnTerminate = null;
            m_OnIdle = null;
            m_OnOutput = null;
            m_OnGetSystemTimeEvent = null;

            m_Thread = null;
            m_Terminate = false;
            m_IntEvent = null;
            m_Locked = 0;
            m_TaskMode = false;
            m_TlsIndex = new ThreadLocal<int>();
            m_SysSem = new System.Threading.Semaphore(1, 1);
            m_CallbackSem = new System.Threading.Semaphore(1, 1);
            m_Lock = 0;
        }
Exemplo n.º 6
0
        bool IKernel.Dispatch()
        {
            bool        Result;
            Task        Task;
            ICPUContext CPUContext;

            Task = Nucleus.GetTask(ID.TSK_SELF);

            if ((Task != null) && (Task.rtsk.tskstat != TSKSTAT.TTS_DMT))
            {
                CPUContext = Task.GetCPUContext();

                Task.Ready();

                Result = CPUContext.Dispatch();
            }
            else
            {
                m_IntEvent.Set();
                Result = !IsTerminated();
            }

            return(Result);
        }
Exemplo n.º 7
0
 internal static void sys_init(lwip lwip, Nucleus nucleus)
 {
     lwip.sys = new sys(lwip, nucleus);
 }
Exemplo n.º 8
0
 public sys(lwip lwip, Nucleus nucleus)
 {
     this.lwip = lwip;
     m_Nucleus = nucleus;
 }
Exemplo n.º 9
0
 public Mailbox(ID mbxid, ref T_CMBX pk_cmbx, Nucleus pNucleus)
 {
     m_MbxID = mbxid;
     m_cmbx = pk_cmbx;
     m_Nucleus = pNucleus;
 }
Exemplo n.º 10
0
 public EventFlag(ID flgid, ref T_CFLG pk_cflg, Nucleus pNucleus)
 {
     m_FlgID   = flgid;
     m_cflg    = pk_cflg;
     m_Nucleus = pNucleus;
 }
Exemplo n.º 11
0
 public Mailbox(ID mbxid, ref T_CMBX pk_cmbx, Nucleus pNucleus)
 {
     m_MbxID   = mbxid;
     m_cmbx    = pk_cmbx;
     m_Nucleus = pNucleus;
 }
Exemplo n.º 12
0
 internal static void sys_init(lwip lwip, Nucleus nucleus)
 {
     lwip.sys = new sys(lwip, nucleus);
 }
Exemplo n.º 13
0
 public sys(lwip lwip, Nucleus nucleus)
 {
     this.lwip = lwip;
     m_Nucleus = nucleus;
 }
Exemplo n.º 14
0
        void MainLoop()
        {
            int  intNo;
            ID   tskid;
            Task task;
            bool noIntr;

            Start();

            m_Nucleus.Start();

            do
            {
                ProcInterrupt();

                do
                {
                    noIntr = true;
                    for (intNo = 0; intNo < m_InProcIntr.Length; intNo++)
                    {
                        if (IsTerminated())
                        {
                            return;
                        }

                        if (InterruptEnabled(intNo))
                        {
                            noIntr = false;

                            ClearInterrupt(intNo);

                            if (intNo == Nucleus.SysTmrIntNo)
                            {
                                m_Nucleus.OnSysTime();
                            }

                            tskid = CallIntHandler(intNo);

                            if (tskid != ID.TSK_NULL)
                            {
                                Task wTask;

                                wTask = Nucleus.GetTask(tskid);
                                if (wTask != null)
                                {
                                    wTask.Wakeup();
                                }
                            }
                        }
                    }
                }while (!noIntr);

                m_Nucleus.Scheduling();

                task = m_Nucleus.GetScheduledTask();
                if (task == null)
                {
                    Idle();
                }
                else
                {
                    m_Current = (CPUContext)task.GetCPUContext();

                    task.Run();

                    m_Current.PopContext();

                    UnlockCPU();

                    m_TaskMode = true;

                    if (!m_IntEvent.WaitOne())
                    {
                        Terminate();
                    }

                    m_TaskMode = false;

                    LockCPU();

                    CPUContext CPUContext = (CPUContext)m_Current;
                    m_Current = null;

                    if (CPUContext.IsReleased())
                    {
                        CPUContext.Wait();
                        CPUContext.ClearTask();
                    }
                    else
                    {
                        CPUContext.PushContext();
                    }
                }

                task = m_Nucleus.GetCurrentTask();
                if (task != null)
                {
                    task.Ready();
                }
            } while (!IsTerminated());
        }
Exemplo n.º 15
0
 public EventFlag(ID flgid, ref T_CFLG pk_cflg, Nucleus pNucleus)
 {
     m_FlgID = flgid;
     m_cflg = pk_cflg;
     m_Nucleus = pNucleus;
 }