《操作系统》的实验代码。
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.

31 lines
559 B

преди 12 години
  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. #include <assert.h>
  7. #include <atomic.h>
  8. #include <sched.h>
  9. static inline bool
  10. __intr_save(void) {
  11. if (read_eflags() & FL_IF) {
  12. intr_disable();
  13. return 1;
  14. }
  15. return 0;
  16. }
  17. static inline void
  18. __intr_restore(bool flag) {
  19. if (flag) {
  20. intr_enable();
  21. }
  22. }
  23. #define local_intr_save(x) do { x = __intr_save(); } while (0)
  24. #define local_intr_restore(x) __intr_restore(x);
  25. #endif /* !__KERN_SYNC_SYNC_H__ */