#ifndef __KERN_MM_VMM_H__ #define __KERN_MM_VMM_H__ #include #include #include #include #include #include //pre define struct mm_struct; // the virtual continuous memory area(vma), [vm_start, vm_end), // addr belong to a vma means vma.vm_start<= addr mm_count; } static inline void set_mm_count(struct mm_struct *mm, int val) { mm->mm_count = val; } static inline int mm_count_inc(struct mm_struct *mm) { mm->mm_count += 1; return mm->mm_count; } static inline int mm_count_dec(struct mm_struct *mm) { mm->mm_count -= 1; return mm->mm_count; } static inline void lock_mm(struct mm_struct *mm) { if (mm != NULL) { down(&(mm->mm_sem)); if (current != NULL) { mm->locked_by = current->pid; } } } static inline void unlock_mm(struct mm_struct *mm) { if (mm != NULL) { up(&(mm->mm_sem)); mm->locked_by = 0; } } #endif /* !__KERN_MM_VMM_H__ */