Exemplo n.º 1
0
 public Page(Frame frame)
 {
     timeAssigned = 0;
     timesUsed = 0;
     state = -1;
     this.frame = frame;
 }
Exemplo n.º 2
0
        public Process(int id, int ioTime, int clock, int frameSize, int diskTime)
        {
            Random rand = new Random();

            curFrames = 0;
            framesDone = 0;
            this.id = "P" + id;
            realID = id;
            arrivalTime = clock;

            size = (rand.Next(0, 60) * 4) + 16;

            frames = (size + frameSize - 1) / frameSize;
            framesLocation = new Frame[frames];

            for (int i = 0; i < framesLocation.Length; i++) {
                framesLocation[i] = new Frame();
                framesLocation[i].parent = this;
                framesLocation[i].frameId = i + 1;
            }

            cpuUse = rand.Next(2, 15);
            cpuTime = rand.Next(1, cpuUse - 1);
            curTime = 0;

            if (rand.NextDouble() > 0.5) {
                usesIO = true;
            }
            else {
                usesIO = false;
            }

            if (cpuTime != 1) {
                IO_initTime = rand.Next(1, (cpuTime - 1));
                disk_initTime = rand.Next(1, (cpuTime - 1));
            }
            else {
                IO_initTime = 1;
                disk_initTime = 1;
            }

            IO_totalTime = ioTime;
            IO_curTime = 0;

            disk_totalTime = diskTime;
            disk_curTime = 0;

            status = "Hold";
        }