QEMU的时间

0x1 时间的种类

// timer.h
typedef enum {
    QEMU_CLOCK_REALTIME = 0,
    QEMU_CLOCK_VIRTUAL = 1,
    QEMU_CLOCK_HOST = 2,
    QEMU_CLOCK_VIRTUAL_RT = 3,
    QEMU_CLOCK_MAX
} QEMUClockType;

0x11 QEMU_CLOCK_REALTIME: Real time clock

The real time clock should be used only for stuff which does not change the virtual machine state,
as it runs even if the virtual machine is stopped.

不受虚拟系统的影响,随时间流逝而累加计数

0x12 QEMU_CLOCK_VIRTUAL: virtual clock

QEMU_CLOCK_VIRTUAL: virtual clock
The virtual clock only runs during the emulation.
It stops when the virtual machine is stopped.

虚拟时钟,记录GuestOS的时间滴答

0x13 QEMU_CLOCK_HOST: host clock

QEMU_CLOCK_HOST: host clock
The host clock should be used for device models that emulate accurate real time sources.
It will continue to run when the virtual machine is suspended,
and it will reflect system time changes the host may undergo (e.g. due to NTP).

HostOs的时间,类似墙上时钟,修改宿主机系统时间会改变这个时间

0x14 QEMU_CLOCK_VIRTUAL_RT: realtime clock used for icount warp

Outside icount mode, this clock is the same as @QEMU_CLOCK_VIRTUAL.
In icount mode, this clock counts nanoseconds while the virtual machine is running.
It is used to increase @QEMU_CLOCK_VIRTUAL while the CPUs are sleeping and thus not executing instructions.

在非icount模式下和QEMU_CLOCK_VIRTUAL相同,
在icount模式下于与QEMU_CLOCK_VIRTUAL不同的是在虚拟cpu休眠的时候该值也会累加

0x2 使用

0x21 获取时间

int64_t qemu_clock_get_ns(QEMUClockType type)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值