Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 0321109 in mainline


Ignore:
Timestamp:
2010-05-02T13:45:44Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
6193351
Parents:
9150781
Message:

Add as_hold() and as_release().

Location:
kernel/generic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/mm/as.h

    r9150781 r0321109  
    229229extern as_t *as_create(int);
    230230extern void as_destroy(as_t *);
     231extern void as_hold(as_t *);
     232extern void as_release(as_t *);
    231233extern void as_switch(as_t *, as_t *);
    232234extern int as_page_fault(uintptr_t, pf_access_t, istate_t *);
  • kernel/generic/src/mm/as.c

    r9150781 r0321109  
    11/*
    2  * Copyright (c) 2001-2006 Jakub Jermar
     2 * Copyright (c) 2010 Jakub Jermar
    33 * All rights reserved.
    44 *
     
    258258
    259259        slab_free(as_slab, as);
     260}
     261
     262/** Hold a reference to an address space.
     263 *
     264 * Holding a reference to an address space prevents destruction of that address
     265 * space.
     266 *
     267 * @param a             Address space to be held.
     268 */
     269void as_hold(as_t *as)
     270{
     271        atomic_inc(&as->refcount);
     272}
     273
     274/** Release a reference to an address space.
     275 *
     276 * The last one to release a reference to an address space destroys the address
     277 * space.
     278 *
     279 * @param a             Address space to be released.
     280 */
     281void as_release(as_t *as)
     282{
     283        if (atomic_predec(&as->refcount) == 0)
     284                as_destroy(as);
    260285}
    261286
Note: See TracChangeset for help on using the changeset viewer.