Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/kern/include/vm/swap.h
2096 views
1
#ifndef _VM_SWAP_H
2
#define _VM_SWAP_H
3
4
#include <bitmap.h>
5
6
#define INVALID_SWAPADDR 0
7
#define SWAP_DEVICE "lhd0raw:"
8
#define SWAP_MIN_FACTOR 40
9
10
#define LOCK_SWAP() (lock_acquire(lk_sw))
11
#define UNLOCK_SWAP() (lock_release(lk_sw))
12
13
#define LOCK_PAGING_GIANT() KASSERT(curthread->t_vmp_count == 0 || curthread->t_clone ); lock_acquire(giant_paging_lock)
14
#define UNLOCK_PAGING_GIANT() (lock_release(giant_paging_lock))
15
#define LOCK_PAGING_IF_POSSIBLE() KASSERT( curthread->t_vmp_count == 0 || curthread->t_clone ); if( curthread != NULL && !curthread->t_in_interrupt ) lock_acquire( giant_paging_lock )
16
#define UNLOCK_PAGING_IF_POSSIBLE() if( curthread != NULL && !curthread->t_in_interrupt ) lock_release( giant_paging_lock )
17
18
/**
19
* holds statistics regarding swapping.
20
* ss_total: total number of pages we can hold.
21
* ss_free: free pages count.
22
* ss_reserved: how many of them are reserved.
23
*/
24
struct swap_stats {
25
unsigned int ss_total;
26
unsigned int ss_free;
27
unsigned int ss_reserved;
28
unsigned int ss_used;
29
};
30
31
void swap_bootstrap( void );
32
off_t swap_alloc(void);
33
void swap_in( paddr_t, off_t );
34
void swap_out( paddr_t, off_t );
35
void swap_dealloc( off_t );
36
int swap_reserve(unsigned);
37
void swap_unreserve(unsigned);
38
39
extern struct lock *giant_paging_lock;
40
41
#endif
42
43