执行块的,我想提一个问题有关使用此功能时间QEMU
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
其实IM在QEMU
执行转换块时获取时间信息,但我不知道,它返回在客户处理器中执行转换块的时间。
所以能有人给我一些提示?
感谢名单
执行块的,我想提一个问题有关使用此功能时间QEMU
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
其实IM在QEMU
执行转换块时获取时间信息,但我不知道,它返回在客户处理器中执行转换块的时间。
所以能有人给我一些提示?
感谢名单
非KVM,软MMU QEMU !!!:
qemu_clock_get_ns(QEMUClockType型)表示经过毫微秒指定QEMU参考时钟。有几种参考时钟: 实时,虚拟主机等QEMU_CLOCK_VIRTUAL是计数器,其明确QEMU主回路驱动:该时钟的一个刻度是时间(毫微秒)的仿真的量子。
详情: QEMU假设:
1 guest instruction counter tick = 1 emulated nano second << icount_time_shift
icount_time_shift由 “-icount” COMAND行选项specfied,它默认为3。
为最后期限来实现所有QEMU定时器(在QEMU_CLOCK_VIRTUAL单位)和QEMU从一个最终期限执行转换块到另一个。从纳秒直谈话ICOUNT提供deteremenistic TB代:QEMU主循环事先说时钟根据到在翻译块/链执行的指令NUM(见cpu_exec.c,这里抽象伪代码):
cpu_exec(CPUState env):
# jump here if any synchronous exception occurs: page fault, protection and etc
if(setjmp(env) == exeption)
;#fall through
for(;;):
# if exception/interrupt is pending then handle it here
take_exception_or_interrupt();
while(no_interrupts()) {
# get num instructions that left till next deadline
icount_extra = get_icount_limit();
# find/generate tb accordnace to icount_extra
# Also every instruction that access to IO is the last instruction at block.
# if access to IO cause interrupt we handle it on next iteration
tb = find_tb(env, icount_extra);
# execute tb or tb chain
execute(env, tb);
# increment QEMU_CLOCK_VIRTUAL accordance to guest instructions was executed
# (syncronise with iothread)
update_clock(tb.executed_instr);
# we will take all interrupts at next iteration
间隔通过QEMU_CLOCK_VIRTUAL提供在客定时器/计数器的所有模型用于:例如如果设置你板系统计数器频率至62兆赫,则QEMU做每QEMU_CLOCK_VIRTUAL 16个递增该计数器的单增量。
然后你可以使用qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)在您来宾模型获得模拟的纳米秒的时间间隔。