Changeset 482826d in mainline for generic/src/mm/as.c


Ignore:
Timestamp:
2006-05-31T16:23:19Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
39031cc
Parents:
343fc179
Message:

Function for destroying address space for which there is no other reference in the kernel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/mm/as.c

    r343fc179 r482826d  
    122122                as->asid = ASID_INVALID;
    123123       
     124        as->refcount = 0;
    124125        as->cpu_refcount = 0;
    125126        as->page_table = page_table_create(flags);
     
    128129}
    129130
    130 /** Free Adress space */
    131 void as_free(as_t *as)
    132 {
    133         ASSERT(as->cpu_refcount == 0);
    134 
    135         /* TODO: free as_areas and other resources held by as */
    136         /* TODO: free page table */
     131/** Destroy adress space.
     132 *
     133 * When there are no tasks referencing this address space (i.e. its refcount is zero),
     134 * the address space can be destroyed.
     135 */
     136void as_destroy(as_t *as)
     137{
     138        ipl_t ipl;
     139        bool cond;
     140
     141        ASSERT(as->refcount == 0);
     142       
     143        /*
     144         * Since there is no reference to this area,
     145         * it is safe not to lock its mutex.
     146         */
     147         
     148        ipl = interrupts_disable();
     149        spinlock_lock(&inactive_as_with_asid_lock);
     150        if (as->asid != ASID_INVALID && as->asid != ASID_KERNEL) {
     151                list_remove(&as->inactive_as_with_asid_link);
     152                asid_put(as->asid);
     153        }
     154        spinlock_unlock(&inactive_as_with_asid_lock);
     155
     156        /*
     157         * Destroy address space areas of the address space.
     158         */     
     159        for (cond = true; cond; ) {
     160                btree_node_t *node;
     161               
     162                ASSERT(!list_empty(&as->as_area_btree.leaf_head));
     163                node = list_get_instance(&as->as_area_btree.leaf_head.next, btree_node_t, leaf_link);
     164                if ((cond = node->keys)) {
     165                        as_area_destroy(as, node->key[0]);
     166                        btree_remove(&as->as_area_btree, node->key[0], node);
     167                }
     168        }
     169       
     170        page_table_destroy(as->page_table);
     171
     172        interrupts_restore(ipl);
     173       
    137174        free(as);
    138175}
     
    841878}
    842879
     880/** Destroy page table.
     881 *
     882 * Destroy page table in architecture specific way.
     883 *
     884 * @param page_table Physical address of PTL0.
     885 */
     886void page_table_destroy(pte_t *page_table)
     887{
     888        ASSERT(as_operations);
     889        ASSERT(as_operations->page_table_destroy);
     890
     891        as_operations->page_table_destroy(page_table);
     892}
     893
    843894/** Lock page table.
    844895 *
Note: See TracChangeset for help on using the changeset viewer.