Example #1
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;
 }
Example #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;
 }
Example #3
0
        public ER CreateSemaphore(ID semid, ref T_CSEM pk_csem, out ID p_semid)
        {
            int i;

            //if (pk_csem == null)
            //	return ER.E_PAR;

            if (semid == ID.ID_AUTO)
            {
                //if (p_semid == 0)
                //	return ER.E_PAR;

                semid.Value = 1;

                for (i = 0; ; i++)
                {
                    if (i >= m_SemaphoreTable.Count)
                    {
                        m_SemaphoreTable.Add(new Semaphore(semid, ref pk_csem, this));
                        break;
                    }

                    if (semid == m_SemaphoreTable[i].SemID)
                    {
                        semid.Value++;
                    }
                    else
                    {
                        m_SemaphoreTable.Insert(i, new Semaphore(semid, ref pk_csem, this));
                        break;
                    }
                }
                p_semid = semid;
            }
            else
            {
                ID tmpid;

                p_semid = ID.NULL;

                for (i = 0; i < m_SemaphoreTable.Count; i++)
                {
                    tmpid = m_SemaphoreTable[i].SemID;

                    if (semid == tmpid)
                    {
                        return(ER.E_OBJ);
                    }
                    else if (semid < tmpid)
                    {
                        break;
                    }
                }
                m_SemaphoreTable.Insert(i, new Semaphore(semid, ref pk_csem, this));
            }

            return(ER.E_OK);
        }
Example #4
0
        public ER cre_sem(ID semid, ref T_CSEM pk_csem, out ID p_semid)
        {
            ER Result = ER.E_NOEXS;

            p_semid = ID.NULL;

            if (g_Kernel == null)
                return ER.E_DLT;

            g_Kernel.LockCPU();
            try {
                Result = g_Kernel.Nucleus.CreateSemaphore(semid, ref pk_csem, out p_semid);
            }
            finally {
                g_Kernel.UnlockCPU();
            }

            return Result;
        }
Example #5
0
        public ER CreateSemaphore(ID semid, ref T_CSEM pk_csem, out ID p_semid)
        {
            int i;

            //if (pk_csem == null)
            //	return ER.E_PAR;

            if (semid == ID.ID_AUTO) {
                //if (p_semid == 0)
                //	return ER.E_PAR;

                semid.Value = 1;

                for (i = 0; ; i++) {
                    if (i >= m_SemaphoreTable.Count) {
                        m_SemaphoreTable.Add(new Semaphore(semid, ref pk_csem, this));
                        break;
                    }

                    if (semid == m_SemaphoreTable[i].SemID) {
                        semid.Value++;
                    }
                    else {
                        m_SemaphoreTable.Insert(i, new Semaphore(semid, ref pk_csem, this));
                        break;
                    }
                }
                p_semid = semid;
            }
            else {
                ID tmpid;

                p_semid = ID.NULL;

                for (i = 0; i < m_SemaphoreTable.Count; i++) {
                    tmpid = m_SemaphoreTable[i].SemID;

                    if (semid == tmpid) {
                        return ER.E_OBJ;
                    }
                    else if (semid < tmpid) {
                        break;
                    }
                }
                m_SemaphoreTable.Insert(i, new Semaphore(semid, ref pk_csem, this));
            }

            return ER.E_OK;
        }