Esempio n. 1
0
        /*
         * Constructor - extract the algo type, frame-size and sequence from the specification string
         */
        public PagingSequencer(String specLine, bool repeatsAsBlank)
        {
            String[] components = specLine.Split(',');
            this.repeatsAsBlank = repeatsAsBlank;

            if (components.Length < 2)
            {
                return;
            }

            // algorithm code
            String algoCode = components[0];

            try
            {
                // framesize
                int frameSize = int.Parse(components[1]);

                // sequence
                sequence = new int[components.Length - 2];
                for (int i = 2; i < components.Length; i++)
                {
                    sequence[i - 2] = int.Parse(components[i]);
                }

                // prepare the algorithm
                switch (algoCode.ToLower())
                {
                case "f":
                    algo = new FIFOPaging(frameSize);
                    break;

                case "l":
                    algo = new LRUPaging(frameSize);
                    break;

                case "o":
                    algo = new OptimalPaging(frameSize, sequence);
                    break;
                }
            }
            catch (Exception) { /*eat => algo will be null */ }
        }
        /*
         * Constructor - extract the algo type, frame-size and sequence from the specification string
         */
        public PagingSequencer(String specLine, bool repeatsAsBlank)
        {
            String[] components = specLine.Split(',');
            this.repeatsAsBlank = repeatsAsBlank;

            if (components.Length < 2) return;

            // algorithm code
            String algoCode = components[0];

            try
            {
                // framesize
                int frameSize = int.Parse(components[1]);

                // sequence
                sequence = new int[components.Length - 2];
                for (int i = 2; i < components.Length; i++)
                    sequence[i - 2] = int.Parse(components[i]);

                // prepare the algorithm
                switch (algoCode.ToLower())
                {
                    case "f":
                        algo = new FIFOPaging(frameSize);
                        break;
                    case "l":
                        algo = new LRUPaging(frameSize);
                        break;
                    case "o":
                        algo = new OptimalPaging(frameSize, sequence);
                        break;
                }
            }
            catch (Exception) {/*eat => algo will be null */}
        }