Subversion Repositories HelenOS-historic

Rev

Rev 1266 | Rev 1468 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1266 Rev 1380
Line 37... Line 37...
37
#include <mm/frame.h>
37
#include <mm/frame.h>
38
#include <arch/types.h>
38
#include <arch/types.h>
39
#include <typedefs.h>
39
#include <typedefs.h>
40
#include <memstr.h>
40
#include <memstr.h>
41
#include <adt/hash_table.h>
41
#include <adt/hash_table.h>
42
#include <synch/spinlock.h>
42
#include <synch/mutex.h>
43
 
43
 
44
static pte_t *ht_create(int flags);
44
static pte_t *ht_create(int flags);
45
 
45
 
46
static void ht_lock(as_t *as, bool lock);
46
static void ht_lock(as_t *as, bool lock);
47
static void ht_unlock(as_t *as, bool unlock);
47
static void ht_unlock(as_t *as, bool unlock);
Line 64... Line 64...
64
 */
64
 */
65
pte_t *ht_create(int flags)
65
pte_t *ht_create(int flags)
66
{
66
{
67
    if (flags & FLAG_AS_KERNEL) {
67
    if (flags & FLAG_AS_KERNEL) {
68
        hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations);
68
        hash_table_create(&page_ht, PAGE_HT_ENTRIES, 2, &ht_operations);
-
 
69
        mutex_initialize(&page_ht_lock);
69
    }
70
    }
70
    return NULL;
71
    return NULL;
71
}
72
}
72
 
73
 
73
/** Lock page table.
74
/** Lock page table.
Line 79... Line 80...
79
 * @param lock If false, do not attempt to lock the address space.
80
 * @param lock If false, do not attempt to lock the address space.
80
 */
81
 */
81
void ht_lock(as_t *as, bool lock)
82
void ht_lock(as_t *as, bool lock)
82
{
83
{
83
    if (lock)
84
    if (lock)
84
        spinlock_lock(&as->lock);
85
        mutex_lock(&as->lock);
85
    spinlock_lock(&page_ht_lock);
86
    mutex_lock(&page_ht_lock);
86
}
87
}
87
 
88
 
88
/** Unlock page table.
89
/** Unlock page table.
89
 *
90
 *
90
 * Unlock address space and page hash table.
91
 * Unlock address space and page hash table.
Line 93... Line 94...
93
 * @param as Address space.
94
 * @param as Address space.
94
 * @param unlock If false, do not attempt to lock the address space.
95
 * @param unlock If false, do not attempt to lock the address space.
95
 */
96
 */
96
void ht_unlock(as_t *as, bool unlock)
97
void ht_unlock(as_t *as, bool unlock)
97
{
98
{
98
    spinlock_unlock(&page_ht_lock);
99
    mutex_unlock(&page_ht_lock);
99
    if (unlock)
100
    if (unlock)
100
        spinlock_unlock(&as->lock);
101
        mutex_unlock(&as->lock);
101
}
102
}