The primary reason for this is that chroot() is escapable, where as pivot_root() is not. In the context of LXC, the pivot_root is done after switching into a private filesystem namespace (CLONE-NEWNS), so…

你可以创建多个hierarchy。通过 # mkdir /cgroup/cpu_and_mem # mount -t cgroup -o cpu,cpuset,memory cpu_and_mem /cgroup/cpu_and_mem 来创建。但多个hierarchy的复杂性导致应用较少。一般即使用初始位置的hierarchy: /sys/fs/cgroup/。 每次在系统中创建新层级时,该系统中的所有任务都是那个层级的默认 cgroup(我们称之为 root cgroup,此 cgroup…

学习future.then这个优雅的粘合剂与协程搭配形成框架的过程 future-state 通常情况下,一个promise仅返回一次future,promise对象会在未来异步操作时set值或者异常,future可以在恰当时候进行get操作。 能达成这样的协作,是因为这对promise/future一起维护了一个数据结构future-state。 template <typename... T>struct future_state {};,看起来是可以同时存放多个值。 还有个无值的特化 template<> struct future_state<>{},内部进行优化删掉了保存数据的成员。 future-state被设计保存泛型值和异常。对值类型要求符合is_nothrow_copy_constructible,…

gc种类分为 1.标记-清除算法 通过标记阶段将所有活动对象做上标记,在清理阶段清除没有标记的死亡对象。 gc() { mark_phase() { for(r : roots) mark(r) }; sweep_phase(); } roots 为用户变量、调用栈、寄存器。 优点: 实现简单 gc时不会移动对象 缺点: 内存碎片化、 分配速度慢(与其他的GC算法<复制、标记-压缩>可分配内存是连续的不同,该算法空闲内存为链表,极端情况可能遍历整个链表)、 与写时复制不兼容(同上一样,…