《操作系统》的实验代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
500 B

12 years ago
  1. #ifndef __KERN_SYNC_SYNC_H__
  2. #define __KERN_SYNC_SYNC_H__
  3. #include <x86.h>
  4. #include <intr.h>
  5. #include <mmu.h>
  6. static inline bool
  7. __intr_save(void) {
  8. if (read_eflags() & FL_IF) {
  9. intr_disable();
  10. return 1;
  11. }
  12. return 0;
  13. }
  14. static inline void
  15. __intr_restore(bool flag) {
  16. if (flag) {
  17. intr_enable();
  18. }
  19. }
  20. #define local_intr_save(x) do { x = __intr_save(); } while (0)
  21. #define local_intr_restore(x) __intr_restore(x);
  22. #endif /* !__KERN_SYNC_SYNC_H__ */