Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ProcessInformation        info       = JsonConvert.DeserializeObject <ProcessInformation>(System.IO.File.ReadAllText(@"Processes.json"));
            ProcessSchedularBaseClass _schedular = SchedularFactory.CreateSchedular(info.AlgorithmName);

            Console.WriteLine("_________________________________________________________________");
            Console.WriteLine("Executing Algorithm '{0}'", _schedular);
            Console.WriteLine("_________________________________________________________________");
            _schedular.ReadyQueue    = info.Processes;
            _schedular.CPUBurstTimes = info.BurstTimes;
            _schedular.SortProcessQueue();
            _schedular.Initialize();
            _schedular.Quanta = info.Quanta;
            _schedular.ExecuteAlgorithm();
            _schedular.DisplayFinalInformation();

            //int n = 1;
            //while (n < info.Quanta)
            //{
            //    _schedular = SchedularFactory.CreateSchedular(info.AlgorithmName);
            //    Console.WriteLine("_________________________________________________________________");
            //    Console.WriteLine("Executing Algorithm '{0}'", _schedular);
            //    Console.WriteLine("_________________________________________________________________");
            //    _schedular.ReadyQueue = info.Processes;
            //    _schedular.CPUBurstTimes = info.BurstTimes;
            //    _schedular.SortProcessQueue();
            //    _schedular.Initialize();
            //    _schedular.Quanta = info.Quanta;
            //    _schedular.ExecuteAlgorithm();
            //    _schedular.DisplayFinalInformation();
            //}
            Console.ReadKey();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an instance of an <see cref="ProcessSchedularBaseClass"/>.
        /// </summary>
        /// <param name="name"></param>
        /// <returns><see cref="ProcessSchedularBaseClass"/> instance if the strategy was found in one of the plugin assemblies; otherwise null.</returns>
        public static ProcessSchedularBaseClass CreateSchedular(string name)
        {
            ProcessSchedularBaseClass _rtnSchedular = null;

            Assembly assembly = Assembly.GetExecutingAssembly();

            foreach (Type type in assembly.GetTypes())
            {
                if (type.Name.Equals(name))
                {
                    _rtnSchedular = Activator.CreateInstance(type) as ProcessSchedularBaseClass;
                    break;
                }
            }
            return(_rtnSchedular);
        }