Changeset e17f703 in mainline
- Timestamp:
- 2011-04-16T19:39:59Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e953bda
- Parents:
- 8b6930d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/mm/reserve.c
r8b6930d re17f703 36 36 */ 37 37 38 #include <typedefs.h>39 38 #include <mm/reserve.h> 40 39 #include <mm/frame.h> 40 #include <synch/spinlock.h> 41 #include <typedefs.h> 42 #include <arch/types.h> 43 44 IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(reserve_lock, "reserve_lock"); 45 static ssize_t reserve = 0; 41 46 42 47 bool reserve_try_alloc(size_t size) 43 48 { 44 return true; 49 bool reserved = false; 50 51 irq_spinlock_lock(&reserve_lock, true); 52 if (reserve >= 0 && (size_t) reserve >= size) { 53 reserve -= size; 54 reserved = true; 55 } 56 irq_spinlock_unlock(&reserve_lock, true); 57 58 return reserved; 45 59 } 46 60 47 61 void reserve_force_alloc(size_t size) 48 62 { 63 irq_spinlock_lock(&reserve_lock, true); 64 reserve -= size; 65 irq_spinlock_unlock(&reserve_lock, true); 49 66 } 50 67 51 68 void reserve_free(size_t size) 52 69 { 70 irq_spinlock_lock(&reserve_lock, true); 71 reserve += size; 72 irq_spinlock_unlock(&reserve_lock, true); 53 73 } 54 74
Note:
See TracChangeset
for help on using the changeset viewer.