Subversion Repositories HelenOS-historic

Rev

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

Rev 1587 Rev 1594
Line 134... Line 134...
134
 * the address space can be destroyed.
134
 * the address space can be destroyed.
135
 */
135
 */
136
void as_destroy(as_t *as)
136
void as_destroy(as_t *as)
137
{
137
{
138
    ipl_t ipl;
138
    ipl_t ipl;
139
    link_t *cur;
139
    bool cond;
140
 
140
 
141
    ASSERT(as->refcount == 0);
141
    ASSERT(as->refcount == 0);
142
   
142
   
143
    /*
143
    /*
144
     * Since there is no reference to this area,
144
     * Since there is no reference to this area,
145
     * it is safe not to lock its mutex.
145
     * it is safe not to lock its mutex.
146
     */
146
     */
147
     
-
 
148
    ipl = interrupts_disable();
147
    ipl = interrupts_disable();
149
    spinlock_lock(&inactive_as_with_asid_lock);
148
    spinlock_lock(&inactive_as_with_asid_lock);
150
 
-
 
151
    if (as->asid != ASID_INVALID && as != AS_KERNEL) {
149
    if (as->asid != ASID_INVALID && as != AS_KERNEL) {
152
        if (!as->cpu_refcount)
150
        if (as != AS && as->cpu_refcount == 0)
153
            list_remove(&as->inactive_as_with_asid_link);
151
            list_remove(&as->inactive_as_with_asid_link);
154
        asid_put(as->asid);
152
        asid_put(as->asid);
155
    }
153
    }
156
    spinlock_unlock(&inactive_as_with_asid_lock);
154
    spinlock_unlock(&inactive_as_with_asid_lock);
157
 
155
 
158
    /*
156
    /*
159
     * Destroy address space areas of the address space.
157
     * Destroy address space areas of the address space.
-
 
158
     * The B+tee must be walked carefully because it is
-
 
159
     * also being destroyed.
160
     */
160
     */
161
    for (cur = as->as_area_btree.leaf_head.next; cur != &as->as_area_btree.leaf_head; cur = cur->next) {
161
    for (cond = true; cond; ) {
162
        btree_node_t *node;
162
        btree_node_t *node;
163
        int i;
-
 
164
       
163
 
-
 
164
        ASSERT(!list_empty(&as->as_area_btree.leaf_head));
165
        node = list_get_instance(cur, btree_node_t, leaf_link);
165
        node = list_get_instance(as->as_area_btree.leaf_head.next, btree_node_t, leaf_link);
-
 
166
 
166
        for (i = 0; i < node->keys; i++)
167
        if ((cond = node->keys)) {
167
            as_area_destroy(as, node->key[i]);
168
            as_area_destroy(as, node->key[0]);
-
 
169
        }
168
    }
170
    }
169
 
171
 
170
    btree_destroy(&as->as_area_btree);
172
    btree_destroy(&as->as_area_btree);
171
    page_table_destroy(as->page_table);
173
    page_table_destroy(as->page_table);
172
 
174