Exemple #1
0
        /// <summary>
        /// Get all pcbs in the scheduler in a flat list
        /// </summary>
        /// <returns></returns>
        public List <ProcessControlBlock> GetList()
        {
            List <ProcessControlBlock> list = new List <ProcessControlBlock>();

            foreach (KeyValuePair <string, ExecutionQueue> item in _ioDictionary)
            {
                ExecutionQueue q = item.Value;

                foreach (ProcessControlBlock pcb in q.Pcbs)
                {
                    list.Add(pcb);
                }
            }
            return(list);
        }
Exemple #2
0
        /// <summary>
        /// Adds pcb to the appropriate device queue. If a queue doesnt exist for it create one.
        /// </summary>
        /// <param name="ioDevice"></param>
        /// <param name="pcb"></param>
        public void ScheduleIo(string ioDevice, ProcessControlBlock pcb)
        {
            //log the io request
            pcb.IoRequestsPerformed++;

            //add the io to its queue if it exists, else create a new queue and it
            if (_ioDictionary.ContainsKey(ioDevice))
            {
                _ioDictionary[ioDevice].EnQueue(pcb);
            }
            else
            {
                ExecutionQueue newQ = new ExecutionQueue();
                newQ.EnQueue(pcb);
                _ioDictionary.Add(ioDevice, newQ);
            }

            this._os.Gui.UpdateIoQueueLog();
        }
Exemple #3
0
        /// <summary>
        /// Increment io cycles of pcbs in scheduler
        /// </summary>
        public void StartIo()
        {
            if (this._ioDictionary.Count > 0)
            {
                //decrement the io queues based on setting
                foreach (KeyValuePair <string, ExecutionQueue> item in _ioDictionary)
                {
                    ExecutionQueue q = item.Value;
                    if (this._os.Settings.DecrementAllIo)
                    {
                        item.Value.SimIoAll();
                    }
                    else
                    {
                        item.Value.SimIoTop();
                    }
                }

                //loop through one more time to check if any of the ios are ready. if they are create an event so
                // the cpu will catch it on the next cc
                foreach (KeyValuePair <string, ExecutionQueue> item in _ioDictionary)
                {
                    ExecutionQueue q = item.Value;

                    foreach (ProcessControlBlock p in q.Pcbs)
                    {
                        //create an event that the io is ready
                        if (p.CurrentOperation.Cycles == 0)
                        {
                            EventControlBlock ecb = new EventControlBlock();
                            ecb.Type   = EventType.ReleaseIO;
                            ecb.PcbId  = p.PId;
                            ecb.IoType = p.CurrentOperation.IoType;
                            //add the event to the list that the cpu will check
                            this._os.InterruptProcessor.AddEvent(ecb);
                        }
                    }
                }
            }

            this._os.Gui.UpdateIoQueueCycles();
        }