Esempio n. 1
0
        public void run_1()
        {
            this.setID();
            cpuQueue que = new cpuQueue();

            que.enQueue(cpu1);
            load.Load();
            Thread loadThread = new Thread(() => schedule.load(disk, ram, load.pcbQueue));
            Thread cpuThread1 = new Thread(() => cpu1.execute(ram, load.pcbQueue, schedule, que));

            loadThread.Start();
            cpuThread1.Start();

            while (load.pcbQueue.jobsComplete() == false)
            {
                //do nothing
            }
            if (load.pcbQueue.jobsComplete() == true)
            {
                if (debugMode)
                {
                    load.pcbQueue.displayCoreDump();
                }
                load.pcbQueue.calculateTimes();
                Console.WriteLine("******************************* 1 CPU ***********************************");
                if (debugMode)
                {
                    load.pcbQueue.showMetrics();
                }
                else
                {
                    load.pcbQueue.printTime();
                }
            }
        }
Esempio n. 2
0
 public void execute(RAM ram, pcbQueue pcbQueue, Scheduler schedule, cpuQueue que)
 {
     while (pcbQueue.jobsComplete() == false)
     {
         while (this != que.head || pcbQueue.cpuIterator >= pcbQueue.ramIterator)
         {
             //do nothing
             if (pcbQueue.jobsComplete() == true)
             {
                 return;
             }
             Thread.Yield();
         }
         PCB temp = pcbQueue.queue[pcbQueue.cpuIterator];
         if (debugMode)
         {
             Console.WriteLine("CPU " + this.id + " executing job " + temp.processID);
         }
         pcbQueue.cpuIterator++;
         que.deQueue();
         temp.startTime = DateTime.Now.TimeOfDay;
         temp.waitTime  = temp.startTime - temp.ramLoadTime;
         PopulateInstructionList(ram, temp);
         this.StartWork(temp);
         temp.timeCompleted = DateTime.Now.TimeOfDay;
         if (debugMode)
         {
             temp.core = pcbQueue.getCoreDump(temp, ram);
         }
         temp.executionTime = temp.timeCompleted - temp.startTime;
         temp.complete      = true;
         this.signal(ram, schedule, temp);
         if (debugMode)
         {
             Console.WriteLine("Process " + temp.processID + " complete!");
         }
         que.enQueue(this);
         if (debugMode)
         {
             Console.WriteLine("Jobs complete? " + pcbQueue.jobsComplete());
         }
     }
 }
Esempio n. 3
0
        public void page_run_4()
        {
            this.setID();
            cpuQueue que = new cpuQueue();

            que.enQueue(cpu1);
            que.enQueue(cpu2);
            que.enQueue(cpu3);
            que.enQueue(cpu4);
            load.Load();
            load.pcbQueue.getPageInfo();
            schedule.pageLoad(disk, ram, load.pcbQueue);
            ram.display();
            load.pcbQueue.showPageTable();

            while (load.pcbQueue.jobsComplete() == false)
            {
                //do nothing
            }
            if (load.pcbQueue.jobsComplete() == true)
            {
                load.pcbQueue.displayCoreDump();
                load.pcbQueue.calculateTimes();
                Console.WriteLine("******************************* 4 CPU ***********************************");
                if (debugMode)
                {
                    load.pcbQueue.showMetrics();
                }
                else
                {
                    load.pcbQueue.printTime();
                }
                //ram.showFrameList();


                //ram.getUsed();
            }
        }