Rev 767 | Rev 773 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 767 | Rev 768 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | #include <print.h> |
31 | #include <print.h> |
32 | #include <proc/thread.h> |
32 | #include <proc/thread.h> |
33 | #include <arch.h> |
33 | #include <arch.h> |
34 | #include <panic.h> |
34 | #include <panic.h> |
35 | #include <mm/frame.h> |
35 | #include <mm/frame.h> |
- | 36 | #include <memstr.h> |
|
36 | 37 | ||
37 | #define ITEM_SIZE 256 |
38 | #define ITEM_SIZE 256 |
38 | 39 | ||
39 | /** Fill memory with 2 caches, when allocation fails, |
40 | /** Fill memory with 2 caches, when allocation fails, |
40 | * free one of the caches. We should have everything in magazines, |
41 | * free one of the caches. We should have everything in magazines, |
Line 62... | Line 63... | ||
62 | slab_free(cache1,data1); |
63 | slab_free(cache1,data1); |
63 | if (data2) |
64 | if (data2) |
64 | slab_free(cache2,data2); |
65 | slab_free(cache2,data2); |
65 | break; |
66 | break; |
66 | } |
67 | } |
67 | - | ||
- | 68 | memsetb((__address)data1, ITEM_SIZE, 0); |
|
- | 69 | memsetb((__address)data2, ITEM_SIZE, 0); |
|
68 | *((void **)data1) = olddata1; |
70 | *((void **)data1) = olddata1; |
69 | *((void **)data2) = olddata2; |
71 | *((void **)data2) = olddata2; |
70 | olddata1 = data1; |
72 | olddata1 = data1; |
71 | olddata2 = data2; |
73 | olddata2 = data2; |
72 | }while(1); |
74 | }while(1); |
Line 86... | Line 88... | ||
86 | for (i=0; i<30; i++) { |
88 | for (i=0; i<30; i++) { |
87 | data1 = slab_alloc(cache1, FRAME_ATOMIC); |
89 | data1 = slab_alloc(cache1, FRAME_ATOMIC); |
88 | if (!data1) { |
90 | if (!data1) { |
89 | panic("Incorrect memory size - use another test."); |
91 | panic("Incorrect memory size - use another test."); |
90 | } |
92 | } |
- | 93 | memsetb((__address)data1, ITEM_SIZE, 0); |
|
91 | *((void **)data1) = olddata1; |
94 | *((void **)data1) = olddata1; |
92 | olddata1 = data1; |
95 | olddata1 = data1; |
93 | } |
96 | } |
94 | slab_print_list(); |
97 | slab_print_list(); |
95 | while (1) { |
98 | while (1) { |
96 | data1 = slab_alloc(cache1, FRAME_ATOMIC); |
99 | data1 = slab_alloc(cache1, FRAME_ATOMIC); |
97 | if (!data1) { |
100 | if (!data1) { |
98 | break; |
101 | break; |
99 | } |
102 | } |
- | 103 | memsetb((__address)data1, ITEM_SIZE, 0); |
|
100 | *((void **)data1) = olddata1; |
104 | *((void **)data1) = olddata1; |
101 | olddata1 = data1; |
105 | olddata1 = data1; |
102 | } |
106 | } |
103 | slab_print_list(); |
107 | slab_print_list(); |
- | 108 | printf("Deallocating cache1..."); |
|
- | 109 | while (olddata1) { |
|
- | 110 | data1 = *((void **)olddata1); |
|
- | 111 | slab_free(cache1, olddata1); |
|
- | 112 | olddata1 = data1; |
|
104 | 113 | } |
|
- | 114 | printf("done.\n"); |
|
- | 115 | slab_print_list(); |
|
- | 116 | slab_cache_destroy(cache1); |
|
- | 117 | slab_cache_destroy(cache2); |
|
105 | } |
118 | } |
106 | 119 | ||
107 | void test(void) |
120 | void test(void) |
108 | { |
121 | { |
- | 122 | printf("Running reclaim test .. pass1\n"); |
|
- | 123 | totalmemtest(); |
|
- | 124 | printf("Running reclaim test .. pass2\n"); |
|
109 | totalmemtest(); |
125 | totalmemtest(); |
- | 126 | printf("Reclaim test OK.\n"); |
|
110 | } |
127 | } |