/// <summary> /// Initizlizes the properties of the class. /// </summary> /// <param name="pageIndex">The index of the page to be accessed in the page table.</param> /// <param name="processId">The process requesting the page access.</param> /// <param name="accessType">The operation type: read / write.</param> internal Command(int processId, int pageIndex, PageAccessType accessType) { ProcessId = processId; PageIndex = pageIndex; AccessType = accessType; completed = false; }
/// <summary> /// Generates one command to be appended to the simulation's commands list. /// </summary> /// <param name="pid">Optional parameter. If given a value, the command will be assigned to given pid. /// Otherwise the process id is also randomly generated.</param> /// <returns>The randomly-generated command.</returns> private Command GenerateCommand(List <Process> processes, int pid = -1) { //generate random operation: read / write PageAccessType op = GenerateOperationType(); //pid = -1 => generate random pid (0..OS.ProcessCount) else use that pid if (pid == -1) { pid = Generate(0, processes.Count); } //generate random page number (0..Process.PageTableSize) int pageIndex = Generate(0, processes[pid].PageTableSize); return(new Command(pid, pageIndex, op)); }