public void OneRegisterHasUnservedOrders()
        {
            var takeOutOrders = new int[] { 55, 9 };
            var dineInOrders  = new int[] { 7, 8 };
            var servedOrders  = new int[] { 1, 7, 8, 9 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.False(result);
        }
        public void OrderNumbersAreNotSequential()
        {
            var takeOutOrders = new int[] { 27, 12, 18 };
            var dineInOrders  = new int[] { 55, 31, 8 };
            var servedOrders  = new int[] { 55, 31, 8, 27, 12, 18 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.True(result);
        }
        public void ServedOrdersIsMissingOrdersTest()
        {
            var takeOutOrders = new int[] { 1, 5 };
            var dineInOrders  = new int[] { 2, 3, 6 };
            var servedOrders  = new int[] { 1, 6, 3, 5 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.False(result);
        }
        public void ServedOrdersHasExtraOrders()
        {
            var takeOutOrders = new int[] { 1, 5 };
            var dineInOrders  = new int[] { 2, 3, 6 };
            var servedOrders  = new int[] { 1, 2, 3, 5, 6, 8 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.False(result);
        }
        public void OneRegisterIsEmptyTest()
        {
            var takeOutOrders = new int[] { };
            var dineInOrders  = new int[] { 2, 3, 6 };
            var servedOrders  = new int[] { 2, 3, 6 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.True(result);
        }
        public void RegistersHaveDifferentLengthsTest()
        {
            var takeOutOrders = new int[] { 1, 5 };
            var dineInOrders  = new int[] { 2, 3, 6 };
            var servedOrders  = new int[] { 1, 2, 6, 3, 5 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.False(result);
        }
        public void BothRegistersHaveSameNumberOfOrdersTest()
        {
            var takeOutOrders = new int[] { 1, 4, 5 };
            var dineInOrders  = new int[] { 2, 3, 6 };
            var servedOrders  = new int[] { 1, 2, 3, 4, 5, 6 };
            var result        = FCFS.IsFirstComeFirstServed(takeOutOrders, dineInOrders, servedOrders);

            Assert.True(result);
        }
Beispiel #8
0
        public void FCFSTest()
        {
            init();
            ds._list = stubNumber();
            IStrategy strategy = new FCFS();

            tbRange.Value = 1;
            ds.SetStrategy(strategy);
            ds.runStrategy();

            Assert.AreEqual(10, ds._list.ElementAt(0));
            Assert.AreEqual(2, ds._list.ElementAt(1));
        }
Beispiel #9
0
    void ThreFCFS()
    {
        ProcessCompare compare = new ProcessCompare();
        List <Process> li      = new List <Process>(creationController.GetItens().ToArray());

        li.Sort(compare);
        fcfs = FCFS.Schedulering(li, progressFCFS);

        waitTimeFCFS      = Benchmark.WaitTime(fcfs, li.Count);
        turnarondTimeFCFS = Benchmark.TurnarondTime(fcfs, li);
        responseTimeFCFS  = Benchmark.ResponseTime(fcfs, li);

        Application.Invoke((sender, e) => OnSelectScheduler(SchedulerCombobox, e));
    }
Beispiel #10
0
        private void running()
        {
            int time_quantum = Convert.ToInt32(lfMenu.sliderTimequantum.Value);
            //data = get_data();        // 얕은 복사 실행(이 코드에선 사용금지)
            List <ProcessData> tmp = GenericCopier <List <ProcessData> > .DeepCopy(get_data());    // 깊은 복사 실행

            if (!checkValues(tmp))
            {
                MessageBox.Show("테이블 값의 범위는 우선순위 0~9, 나머지는 1~30 이어야 합니다.\n확인 후 다시 작업을 요청하십시오.", "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            List <ProcessData> data_fcfs = GenericCopier <List <ProcessData> > .DeepCopy(tmp);   // 깊은 복사 실행

            List <ProcessData> data_sjf = GenericCopier <List <ProcessData> > .DeepCopy(tmp);    // 깊은 복사 실행

            List <ProcessData> data_srt = GenericCopier <List <ProcessData> > .DeepCopy(tmp);    // 깊은 복사 실행

            List <ProcessData> data_hrn = GenericCopier <List <ProcessData> > .DeepCopy(tmp);    // 깊은 복사 실행

            List <ProcessData> data_prio = GenericCopier <List <ProcessData> > .DeepCopy(tmp);   // 깊은 복사 실행

            List <ProcessData> data_rrb = GenericCopier <List <ProcessData> > .DeepCopy(tmp);    // 깊은 복사 실행

            fcfs = new FCFS(data_fcfs);
            sjf  = new SJF(data_sjf);
            srt  = new SRT(data_srt);
            hrn  = new HRN(data_hrn);
            prio = new Priority(data_prio);
            rrb  = new RoundRobin(data_rrb, time_quantum);

            List <ProcessData> temp;

            switch (select_flag)
            {
            case ( int )proc.FCFS:
                temp = fcfs.working();
                sjf.working(); srt.working(); hrn.working();
                prio.working(); rrb.working();
                calc_time(fcfs.get_wait_time(), fcfs.get_return_time());
                break;

            case ( int )proc.SJF:
                temp = sjf.working();
                fcfs.working(); srt.working();
                hrn.working(); prio.working(); rrb.working();
                calc_time(sjf.get_wait_time(), sjf.get_return_time());
                break;

            case ( int )proc.SRT:
                temp = srt.working();
                fcfs.working(); sjf.working();
                hrn.working(); prio.working(); rrb.working();
                calc_time(srt.get_wait_time(), srt.get_return_time());
                break;

            case ( int )proc.HRN:
                temp = hrn.working();
                fcfs.working(); sjf.working(); srt.working();
                prio.working(); rrb.working();
                calc_time(hrn.get_wait_time(), hrn.get_return_time());
                break;

            case ( int )proc.PRIORITY:
                temp = prio.working();
                fcfs.working(); sjf.working(); srt.working();
                hrn.working(); rrb.working();
                calc_time(prio.get_wait_time(), prio.get_return_time());
                break;

            case ( int )proc.ROUNDROBIN:
                temp = rrb.working();
                fcfs.working(); sjf.working(); srt.working();
                hrn.working(); prio.working();
                calc_time(rrb.get_wait_time(), rrb.get_return_time());
                break;

            default:
                MessageBox.Show("올바르지 않은 접근입니다.\n확인 후 다시 작업을 요청하십시오.", "오류", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            wait_time[( int )proc.FCFS - 1]       = Convert.ToDouble(string.Format("{0:#0.00}", fcfs.avg_wait()));
            wait_time[( int )proc.SJF - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", sjf.avg_wait()));
            wait_time[( int )proc.SRT - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", srt.avg_wait()));
            wait_time[( int )proc.HRN - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", hrn.avg_wait()));
            wait_time[( int )proc.PRIORITY - 1]   = Convert.ToDouble(string.Format("{0:#0.00}", prio.avg_wait()));
            wait_time[( int )proc.ROUNDROBIN - 1] = Convert.ToDouble(string.Format("{0:#0.00}", rrb.avg_wait()));

            return_time[( int )proc.FCFS - 1]       = Convert.ToDouble(string.Format("{0:#0.00}", fcfs.avg_return()));
            return_time[( int )proc.SJF - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", sjf.avg_return()));
            return_time[( int )proc.SRT - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", srt.avg_return()));
            return_time[( int )proc.HRN - 1]        = Convert.ToDouble(string.Format("{0:#0.00}", hrn.avg_return()));
            return_time[( int )proc.PRIORITY - 1]   = Convert.ToDouble(string.Format("{0:#0.00}", prio.avg_return()));
            return_time[( int )proc.ROUNDROBIN - 1] = Convert.ToDouble(string.Format("{0:#0.00}", rrb.avg_return()));

            ProcessUpdate(temp);
            WaitUpdate();
            ReturnUpdate();
        }