Пример #1
0
        public static void synchronizeCache(PCB job)
        {
            int cacheSize            = job.getCacheSize();
            int startDiskAddress     = job.getJobDiskAddress();
            int currentDiskAddress   = startDiskAddress;
            int currentMemoryAddress = job.getJobMemoryAddress();

            for (int i = 0; currentDiskAddress < startDiskAddress + cacheSize; i++)
            {
                int virtualPage          = job.getAllocatedVirtualPages()[i / RAM.getPageSize()];
                int virtualPageTimesSize = virtualPage * RAM.getPageSize();
                int finalAdd             = virtualPageTimesSize + i % RAM.getPageSize();
                write(job.getAllocatedVirtualPages()[i / RAM.getPageSize()] * RAM.getPageSize() + i % RAM.getPageSize(), job.getCache()[i]);
                Disk.writeDisk(job.getCache()[i], currentDiskAddress);
                currentDiskAddress++;
                currentMemoryAddress++;
            }
        }