### BEGIN /etc/grub.d/10_linux ### menuentry 'Debian GNU/Linux,Linux 3.2.0-4-686-pae' --class debian --class gnu-linux --class gnu --class os { load_video insmod gzio insmod part_msdos insmod ext2 set root='(hd0,msdos11)' search --no-floppy --fs-uuid --set=root ee17a8a7-1585-4ebb-887e-f29d9477f679 echo '载入 Linux 3.2.0-4-686-pae ...' linux /boot/vmlinuz-3.2.0-4-686-pae root=UUID=ee17a8a7-1585-4ebb-887e-f29d9477f679 ro quiet echo '载入初始化内存盘...' initrd /boot/initrd.img-3.2.0-4-686-pae } menuentry 'Debian GNU/Linux,Linux 3.2.0-4-686-pae (恢复模式)' --class debian --class gnu-linux --class gnu --class os { load_video insmod gzio insmod part_msdos insmod ext2 set root='(hd0,msdos11)' search --no-floppy --fs-uuid --set=root ee17a8a7-1585-4ebb-887e-f29d9477f679 echo '载入 Linux 3.2.0-4-686-pae ...' linux /boot/vmlinuz-3.2.0-4-686-pae root=UUID=ee17a8a7-1585-4ebb-887e-f29d9477f679 ro single echo '载入初始化内存盘...' initrd /boot/initrd.img-3.2.0-4-686-pae } ### END /etc/grub.d/10_linux ###
### BEGIN /etc/grub.d/20_linux_xen ### ### END /etc/grub.d/20_linux_xen ###
### BEGIN /etc/grub.d/30_os-prober ### menuentry "Windows Vista (loader) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs set root='(hd0,msdos1)' search --no-floppy --fs-uuid --set=root 000A41F2000009A5 chainloader +1 } menuentry "Arch (on /dev/sda13)" --class gnu-linux --class gnu --class os { insmod part_msdos insmod ext2 set root='(hd0,msdos13)' search --no-floppy --fs-uuid --set=root eb352014-f4ce-4479-b2ad-ea222d197dc3 linux /boot/vmlinuz-linux root=/dev/sda13 initrd /boot/initramfs-linux.img }
menuentry "Linux From Scratch (SVN-20130711) (on /dev/sda9)" --class gnu-linux --class gnu --class os { insmod part_msdos insmod ext2 set root='(hd0,msdos9)' search --no-floppy --fs-uuid --set=root 0b97772d-0998-4749-b8c2-69a25bade4c5 linux /boot/vmlinuz-3.10-lfs-SVN-20130711 root=/dev/sda9 } ### END /etc/grub.d/30_os-prober ###
The general idea is that instead of having a polling loop (e.g. while( *foo == 0) {}) you set up the monitor (using monitor) then check the condition, then (if the condition hasn’t happened) wait for the monitor to be triggered (using mwait). This allows the CPU to consume less power (and/or lets a different logical processor in the same core run better) while waiting for the condition to change.
However; there can be false positives (writes to something else in the same cache line) and other things (IRQs) that cause mwait to stop waiting. For that reason you still need to check the condition in a loop; so the whole thing ends up like (e.g.) monitor(foo); while(*foo == 0) { mwait(); }.