Changeset 3342f33 in mainline
- Timestamp:
- 2011-12-09T21:35:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bb7e6fc5
- Parents:
- 12cb03d
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/lib/ra.h
r12cb03d r3342f33 39 39 #include <adt/list.h> 40 40 #include <adt/hash_table.h> 41 #include <synch/spinlock.h> 41 42 42 43 typedef struct { 44 SPINLOCK_DECLARE(lock); 43 45 list_t spans; /**< List of arena's spans. */ 44 46 } ra_arena_t; -
kernel/generic/src/lib/ra.c
r12cb03d r3342f33 53 53 #include <align.h> 54 54 #include <macros.h> 55 #include <synch/spinlock.h> 55 56 56 57 #define USED_BUCKETS 1024 … … 197 198 } 198 199 200 spinlock_initialize(&arena->lock, "arena_lock"); 199 201 list_initialize(&arena->spans); 200 202 list_append(&span->span_link, &arena->spans); … … 216 218 217 219 /* TODO: check for overlaps */ 220 spinlock_lock(&arena->lock); 218 221 list_append(&span->span_link, &arena->spans); 222 spinlock_unlock(&arena->lock); 219 223 return true; 220 224 } … … 395 399 ASSERT(ispwr2(alignment)); 396 400 401 spinlock_lock(&arena->lock); 397 402 list_foreach(arena->spans, cur) { 398 403 ra_span_t *span = list_get_instance(cur, ra_span_t, span_link); … … 402 407 break; 403 408 } 409 spinlock_unlock(&arena->lock); 404 410 405 411 return base; … … 409 415 void ra_free(ra_arena_t *arena, uintptr_t base, size_t size) 410 416 { 417 spinlock_lock(&arena->lock); 411 418 list_foreach(arena->spans, cur) { 412 419 ra_span_t *span = list_get_instance(cur, ra_span_t, span_link); … … 414 421 if (iswithin(span->base, span->size, base, size)) { 415 422 ra_span_free(span, base, size); 423 spinlock_unlock(&arena->lock); 416 424 return; 417 425 } 418 426 } 427 spinlock_unlock(&arena->lock); 419 428 420 429 panic("Freeing to wrong arena (base=%" PRIxn ", size=%" PRIdn ").",
Note:
See TracChangeset
for help on using the changeset viewer.