Changeset 1093620 in mainline
- Timestamp:
- 2006-01-22T16:51:11Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d8d27c
- Parents:
- bd6e392
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/include/mm/buddy.h
rbd6e392 r1093620 46 46 47 47 struct buddy_system { 48 __u8 max_order; 48 __u8 max_order; /**< Maximal order of block which can be stored by buddy system. */ 49 49 link_t *order; 50 50 buddy_system_operations_t *op; -
generic/src/mm/buddy.c
rbd6e392 r1093620 69 69 * Allocate memory for all orders this buddy system will work with. 70 70 */ 71 b->order = (link_t *) early_malloc( max_order* sizeof(link_t));71 b->order = (link_t *) early_malloc((max_order + 1) * sizeof(link_t)); 72 72 if (!b->order) { 73 73 early_free(b); … … 75 75 } 76 76 77 for (i = 0; i < max_order; i++)77 for (i = 0; i <= max_order; i++) 78 78 list_initialize(&b->order[i]); 79 79 … … 96 96 __u8 k; 97 97 98 ASSERT(i < b->max_order); 99 100 for (k=i; k < b->max_order; k++) { 98 /* 99 * If requested block is greater then maximal block 100 * we know immediatly that we cannot satisfy the request. 101 */ 102 if (i > b->max_order) return false; 103 104 /* 105 * Check if any bigger or equal order has free elements 106 */ 107 for (k=i; k <= b->max_order; k++) { 101 108 if (!list_empty(&b->order[k])) { 102 109 return true; … … 119 126 link_t *res, *hlp; 120 127 121 ASSERT(i < b->max_order);128 ASSERT(i <= b->max_order); 122 129 123 130 /* … … 136 143 * the request cannot be satisfied. 137 144 */ 138 if (i == b->max_order - 1)145 if (i == b->max_order) 139 146 return NULL; 140 147 … … 186 193 i = b->op->get_order(b, block); 187 194 188 ASSERT(i < b->max_order);189 190 if (i != b->max_order - 1) {195 ASSERT(i <= b->max_order); 196 197 if (i != b->max_order) { 191 198 /* 192 199 * See if there is any buddy in the list of order i. … … 246 253 printf("-----\t------\t--------\t----------\t---------------\n"); 247 254 248 for (i=0;i < b->max_order; i++) {255 for (i=0;i <= b->max_order; i++) { 249 256 cnt = 0; 250 257 if (!list_empty(&b->order[i])) { -
generic/src/mm/frame.c
rbd6e392 r1093620 153 153 interrupts_restore(ipl); 154 154 155 ASSERT(v == ALIGN_UP(v, FRAME_SIZE << order)); 156 155 157 if (flags & FRAME_KA) 156 158 v = PA2KA(v); -
test/mm/falloc1/test.c
rbd6e392 r1093620 30 30 #include <mm/page.h> 31 31 #include <mm/frame.h> 32 #include <mm/heap.h> 32 33 #include <arch/mm/page.h> 33 34 #include <arch/types.h> 34 35 #include <debug.h> 35 36 36 #define MAX_FRAMES 204837 #define MAX_FRAMES 1024 37 38 #define MAX_ORDER 8 38 #define TEST_RUNS 439 #define TEST_RUNS 2 39 40 40 41 void test(void) { 41 __address frames[MAX_FRAMES];42 __address * frames = (__address *) malloc(MAX_FRAMES*sizeof(__address)); 42 43 int results[MAX_ORDER+1]; 43 44 … … 53 54 allocated = 0; 54 55 for (i=0;i<MAX_FRAMES>>order;i++) { 55 frames[allocated] = frame_alloc(FRAME_NON_BLOCKING , order, &status);56 frames[allocated] = frame_alloc(FRAME_NON_BLOCKING | FRAME_KA, order, &status); 56 57 57 58 if (frames[allocated] % (FRAME_SIZE << order) != 0) { … … 83 84 } 84 85 85 86 free(frames); 86 87 87 88 printf("Test passed\n"); -
test/mm/falloc2/test.c
rbd6e392 r1093620 30 30 #include <mm/page.h> 31 31 #include <mm/frame.h> 32 #include <mm/heap.h> 32 33 #include <arch/mm/page.h> 33 34 #include <arch/types.h> … … 37 38 #include <memstr.h> 38 39 39 #define MAX_FRAMES 12840 #define MAX_ORDER 240 #define MAX_FRAMES 256 41 #define MAX_ORDER 8 41 42 42 43 #define THREAD_RUNS 1 43 #define THREADS 644 #define THREADS 8 44 45 45 46 static void thread(void * arg); … … 54 55 index_t k; 55 56 56 __address frames[MAX_FRAMES];57 __address * frames = (__address *) malloc(MAX_FRAMES * sizeof(__address)); 57 58 58 59 for (run=0;run<THREAD_RUNS;run++) { … … 61 62 printf("Thread #%d: Allocating %d frames blocks ... \n",val, 1<<order); 62 63 allocated = 0; 63 for (i=0;i <MAX_FRAMES>>order;i++) {64 for (i=0;i < (MAX_FRAMES >> order);i++) { 64 65 frames[allocated] = frame_alloc(FRAME_NON_BLOCKING | FRAME_KA,order, &status); 65 66 if (status == 0) { … … 75 76 printf("Thread #%d: Deallocating ... \n", val); 76 77 for (i=0;i<allocated;i++) { 78 77 79 for (k=0;k<=((FRAME_SIZE << order) - 1);k++) { 78 80 if ( ((char *) frames[i])[k] != val ) { … … 82 84 83 85 } 84 86 85 87 frame_free(frames[i]); 86 88 }
Note:
See TracChangeset
for help on using the changeset viewer.