Пример #1
0
        private static void Main(string[] args)
        {
            var dispatchers = new List <IDispatcher>();

            dispatchers.Add(new FirstInFirstOutDispatcher());
            dispatchers.Add(new ShortestProcessNextDispatcher());
            dispatchers.Add(new ShortestRemainingCyclesDispatcher());
            dispatchers.Add(new RoundRobinDispatcher(2));
            dispatchers.Add(new RoundRobinDispatcher(4));
            dispatchers.Add(new RoundRobinDispatcher(8));

            var numOfProcessors = dispatchers.Count;

            var system = new ProcessingSystem(numOfProcessors, dispatchers);

            system.Simulate();
        }
Пример #2
0
        /// <summary>
        ///     Creates the processor with the given parameters.
        /// </summary>
        /// <param name="dispatcher">The algorithm this processor will use to choose the next process to run.</param>
        /// <param name="system">The system that this processor is a part of.</param>
        public Processor(IDispatcher dispatcher, ProcessingSystem system)
        {
            Dispatcher = dispatcher;
            _system    = system;

            ProcessorId = _lastId;
            _lastId++;

            var tabsBuilder = new StringBuilder();

            tabsBuilder.Append('\t', ProcessorId + 1);
            _tabs = tabsBuilder.ToString();

            LocalQueue        = new ConcurrentQueue <Process>();
            CurrentClockCycle = 0;

            ProcessesSeen     = 0;
            _statisticHistory = new List <ProcessStatistics>();
        }