Esempio n. 1
0
        public static void run()
        {
            RAM.init();
            Disk.init();
            PCBManager.init();
            osStartTime = DateTimeOffset.Now.ToUnixTimeMilliseconds();

            Loader loader = new Loader("C:/Users/HOME/Documents/Visual Studio 2017/Projects/OSSImulator/OS-Simulator/OSSImulator/OSSImulator/Program-File.txt");

            loader.Start();

            jobMetricses = new JobMetrics[PCBManager.getJobListSize()];
            for (int i = 0; i < jobMetricses.Length; i++)
            {
                jobMetricses[i] = new JobMetrics();
            }


            string s = Disk.readDisk(2);

            Console.WriteLine("DISK TEST: " + s);

            while (custardStands())
            {
                ready();
                aim((schedulingType != null) ? schedulingType : Schedulingtype.FIFO);
                fire();
            }
        }
Esempio n. 2
0
 public void update(JobMetrics metrics)
 {
     setBlockUsed(metrics.getBlockUsed());
     setTimestamp(metrics.getTimestamp());
     setCpuNo(metrics.getCpuNo());
     setEndRunTime(metrics.getEndRunTime());
     setStartRunTime(metrics.getStartRunTime());
     setStartWaitTime(metrics.getStartWaitTime());
     setEndWaitTime(metrics.getEndWaitTime());
     setJobNumber(metrics.getJobNumber());
     setIos(metrics.getIos());
 }
Esempio n. 3
0
 public static void updateJobMetrics(JobMetrics jobMetrics)
 {
     jobMetricses[jobMetrics.getJobNumber() - 1].update(jobMetrics);
     if (jobMetricses[jobMetrics.getJobNumber() - 1].getWaitTime() > 0)
     {
         totalWaitTime += jobMetricses[jobMetrics.getJobNumber() - 1].getWaitTime();
     }
     if (jobMetricses[jobMetrics.getJobNumber() - 1].getRunTime() > 0)
     {
         totalRunTime += jobMetricses[jobMetrics.getJobNumber() - 1].getRunTime();
     }
     //update job metrics
 }
Esempio n. 4
0
        public void loadJobToRAM(PCB block)
        {
            int jobNo = block.getJobNumber();
            int i     = 0;
            int k;
            int m                  = PCBManager.getPCB(jobNo).getJobInstructionCount();
            int dataCardSize       = block.getInputBuffer() + block.getOutputBuffer() + block.getTemporaryBuffer();
            int memory             = PCBManager.getPCB(jobNo).getJobInstructionCount() + dataCardSize;
            int numPages           = (int)Math.Ceiling((double)memory / (double)RAM.getPageSize());
            int startAddress       = block.getJobDiskAddress();
            int currentDiskAddress = startAddress;
            int physPageNo;
            int virtualPageNo = RAM.getNextAvaliableVirtualPageNumber();

            string[]   chunk;
            List <int> virtualAllocatedPages = RAM.Allocate(numPages);

            if (virtualAllocatedPages.Capacity != 0)
            {
                Console.WriteLine(jobNo);
                PCBManager.getPCB(jobNo).setJobInMemory(true);
                PCBManager.getPCB(jobNo).setJobMemoryAddress(virtualPageNo * RAM.getPageSize());
                PCBManager.getPCB(jobNo).setProcessStatus(PCB.PROCESS_STATUS.READY);
                PCBManager.getPCB(jobNo).setPagesNeeded(numPages);
                PCBManager.getPCB(jobNo).setAllocatedVirtualPages(virtualAllocatedPages);

                int n = RAM.getNextAvaliableVirtualPageNumber();
                for (int j = 0; j < virtualAllocatedPages.Capacity; j++)
                {
                    physPageNo = RAM.getPhysicalPageNumber(virtualAllocatedPages[j]);
                    chunk      = Disk.getChunk(currentDiskAddress, calculateChunkSize(block, currentDiskAddress));
                    try
                    {
                        RAM.fillPage(physPageNo, chunk);
                    }
                    catch (Exception e)
                    {
                    }
                    currentDiskAddress += RAM.getPageSize();
                }
                JobMetrics metrics = new JobMetrics();
                metrics.setTimestamp(DateTimeOffset.Now.ToUnixTimeMilliseconds());
                metrics.setJobNumber(jobNo);
                metrics.setStartWaitTime(metrics.getTimestamp());
                metrics.setBlocksUsed(memory);
                Driver.jobMetricses[jobNo - 1].update(metrics);
                Driver.shortTermScheduler.addToReadyQueue(PCBManager.getPCB(jobNo));
            }
        }