os_utils.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:pico 作者: andresriancho 项目源码 文件源码
def setCPUAffinity():
    """
    :note: Child processes inherit the parent's affinity.
    """
    cpus = multiprocessing.cpu_count()
    libc = cdll.LoadLibrary("libc.so.6")

    # Using zero as first parameter means "self PID"
    res = libc.sched_setaffinity(0, 4, byref(c_int(0x00000001 << (cpus - 1))))

    # Give our process a chance to migrate to a different CPU if necessary
    time.sleep(0.25)
    return res
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号