Latch Level All latches have a level in the range 0–14. The level is predefined and permanent. The levels facilitate operations on shared structures and avoid deadlocks. Usually a process can request a latch X after obtaining latch Y, if and only if level X > level (某个Process获取2个latch,唯一情况是当前获取的Cur_level>Req_level,如:) Process A 当前Hold 10,请求获取6的,是可以的 on a multi-CPU system, different CPUs can be modifying memory at the same time. Ideally, the entire “check and change” operation needs to be a single CPU instruction so that it cannot be split into two pieces and descheduled in mid-change, but the key feature is that latching can work safely only if a single CPU can guarantee that the entire operation cannot be interrupted and, if you’re running with multiple CPUs, that the same memory location cannot be modified by two CPUs at the same time. The latter requirement leads to special CPU instructions that do things like locking the memory bus to ensure that only one CPU at a time can access the critical location.

Latch用途: 对于多CPU的系统,在同一时间点每个CPU都可以修改同一个内存.在理想的状态下,该’检查,更改’操作是由1个CPU来完成的,因此不会被分成2个时间片带来的中间更改。 Latch的作用就是安全的保护1个CPU独立的完成这个操作,而不会被其他的CPU干扰(其他CPU可能请求更改同一个内存mem)。保证了1个CPU在同一时间只能更改1个内存Mem。