《操作系统》的实验代码。
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

28 rader
500 B

  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__ */