Changeset 567 for trunk/kernel/mm/khm.c
- Timestamp:
- Oct 5, 2018, 12:01:52 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/mm/khm.c
r551 r567 1 1 /* 2 * khm.c - kernel heap manager implementation.2 * khm.c - Kernel Heap Manager implementation. 3 3 * 4 4 * Authors Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016 )5 * Alain Greiner (2016,2017,2018) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 26 26 #include <hal_kernel_types.h> 27 27 #include <hal_special.h> 28 #include < spinlock.h>28 #include <busylock.h> 29 29 #include <bits.h> 30 30 #include <printk.h> … … 44 44 45 45 // initialize lock 46 spinlock_init( &khm->lock);46 busylock_init( &khm->lock , LOCK_KHM_STATE ); 47 47 48 48 // compute kernel heap size … … 78 78 79 79 // get lock protecting heap 80 uint32_t irq_state; 81 spinlock_lock_busy( &khm->lock, &irq_state ); 80 busylock_acquire( &khm->lock ); 82 81 83 82 // define a starting block to scan existing blocks … … 93 92 if( (intptr_t)current >= (khm->base + khm->size) ) // heap full 94 93 { 95 spinlock_unlock_busy(&khm->lock, irq_state);94 busylock_release(&khm->lock); 96 95 97 96 printk("\n[ERROR] in %s : failed to allocate block of size %d\n", … … 123 122 124 123 // release lock protecting heap 125 spinlock_unlock_busy( &khm->lock, irq_state);124 busylock_release( &khm->lock ); 126 125 127 126 return (char*)current + sizeof(khm_block_t); … … 141 140 142 141 // get lock protecting heap 143 spinlock_lock(&khm->lock);142 busylock_acquire(&khm->lock); 144 143 145 144 assert( (current->busy == 1) , "page already freed" ); … … 159 158 160 159 // release lock protecting heap 161 spinlock_unlock( &khm->lock );160 busylock_release( &khm->lock ); 162 161 } 163 162
Note: See TracChangeset
for help on using the changeset viewer.