私は Java で NACHOS フェーズ 3 プロジェクト (キャッシングと仮想メモリ) を行っています。以下の関数を実装する際にいくつかの混乱があります。
/**
* Restore the state of this process after a context switch. Called by
* UThread.restoreState()
*/
public void restoreState() {
// Invalidate all TLB entries;
for(int i=0; i < Machine.processor().getTLBSize(); i++){
Lib.debug(dbgVM, "Invalidating TLB on context switch.");
TranslationEntry entry = Machine.processor().readTLBEntry(i);
entry.valid = false;
Machine.processor().writeTLBEntry(i, entry);
}
syncPageTable();
}
/**
* Called when the process is context switched in. Synchs the process
* pagetable with the global one so that read/writeVirtualMemory calls
* can proceed as they would normally in the UserProcess class.
*/
private void syncPageTable(){
for(TranslationEntry e : pageTable){
TranslationEntry f = vmk.lookupAddress(super.getPid(), e.vpn);
if(f == null || f.valid == false){
e.valid = false;
}else if(f != null){
f.valid = true;
}
}
}
ここで、vmk = (VMKernel)Kernel.kernel; . syncPageTable()関数を理解していません。for 句内のTranslationEntry e : pageTableの意味と、if-else ブロックによって実際にチェックされているのは何ですか?