爱意满满的作品展示区。
sockpuppet9527

virtio spec 1.1 , 发现了个非原子资源的使用方法

  •  
  •   sockpuppet9527 · Mar 11, 2020 · 1629 views
    This topic created in 2266 days ago, the information mentioned may be changed or developed.

    2.4.1 Driver Requirements: Device Configuration Space

    原文写的说:驱动不能假定从大于 32 位宽的字段进行的读取是原子的。 然后他提供了建议读方式:

    do {
    	before = get_config_generation(device);
    	// read config entry/entries.
    	after = get_config_generation(device);
    } while (after != before);
    

    看起来得在 before 和 after 之中做完所有初始化的事情啊? 假如两者不一致,还得重新做一遍

    以前我想如果非原子资源的话,加把锁或者尽量保证数据原子性。 看起来遇到驱动不好加锁的场景,这个办法也是非常 trick 的。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1068 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 18:28 · PVG 02:28 · LAX 11:28 · JFK 14:28
    ♥ Do have faith in what you're doing.