The reference of the currently active translation map shouldn't be released

until the data it protects isn't in active use anymore. Previously it would
release the translation map and therefore the page directory reference while
the page dir was still set on the CPU, as only the actual call to
i386_context_switch() will replace the page directory in the control register.
This didn't cause any harm though, as during the context switch interrupts are
disabled and therefore the page directory would only be deferred_delete()ed and
not directly freed/overwritten. Still this is logically more correct.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32216 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2009-08-09 17:39:05 +00:00
parent eef09d5cae
commit 50d22f83ef
1 changed files with 6 additions and 2 deletions

View File

@ -384,17 +384,21 @@ arch_thread_context_switch(struct thread *from, struct thread *to)
atomic_or(&toMap->active_on_cpus, (uint32)1 << cpu);
// assign the new map to the CPU
activeMap->RemoveReference();
toMap->AddReference();
cpuData->arch.active_translation_map = toMap;
// get the new page directory
newPageDirectory = (addr_t)toMap->pgdir_phys;
} else
} else {
activeMap = NULL;
newPageDirectory = 0;
}
gX86SwapFPUFunc(from->arch_info.fpu_state, to->arch_info.fpu_state);
i386_context_switch(&from->arch_info, &to->arch_info, newPageDirectory);
if (activeMap != NULL)
activeMap->RemoveReference();
}