On Wednesday 15 December 2010 16:59:24 avadh patel wrote:
> On Wed, Dec 15, 2010 at 6:57 AM, Shen Zhong 
> <[email protected]<mailto:[email protected]>> wrote:
>    However I don't know how to detect the thread context switch in ptlsim.
>    Any ideas? Thanks a lot!!!!!
> 
> Take a look at CR-3 register (control register 3). Value of this
> register is kept unique to the running OS threads so when there is a
> context switch, this value will be changed. So you can make hash of
> value of CR3 and memory addresses to differentiate between multiple
> OS threads.

Not necessarily. Some (old) versions of Linux for example just changed
an entry in the highest-level page table to context switch and left CR3
constant.

While the CPU used to be aware of threads through dedicated strucutres
for each thread, most OSes now manually do the context switching in a
SW way; and each may do it differently. There is no clean cut
interface to know SW threads from the CPU (and hence the simulator), 
but some knowledge of the OS mechanics of the guest need to be applied.
To be sure, check (or even augment with tracing) your OS'es context
switching function.

Stephan

-- 
Stephan Diestelhorst, AMD Operating System Research Center
[email protected]
Tel. +49 (0)351 448 356 719

Advanced Micro Devices GmbH
Einsteinring 24
85609 Dornach / Aschheim

Registration: Dornach, Gemeinde Aschheim
Landkreis Muenchen Registergericht Muenchen
HRB Nr. 43632
General Managers: Alberto Bozzo, Andrew Bowd


_______________________________________________
http://www.marss86.org
Marss86-Devel mailing list
[email protected]
https://www.cs.binghamton.edu/mailman/listinfo/marss86-devel

Reply via email to