Rev 733 | Rev 745 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 733 | Rev 735 | ||
---|---|---|---|
Line 27... | Line 27... | ||
27 | */ |
27 | */ |
28 | #include <print.h> |
28 | #include <print.h> |
29 | #include <test.h> |
29 | #include <test.h> |
30 | #include <mm/page.h> |
30 | #include <mm/page.h> |
31 | #include <mm/frame.h> |
31 | #include <mm/frame.h> |
- | 32 | #include <mm/heap.h> |
|
32 | #include <arch/mm/page.h> |
33 | #include <arch/mm/page.h> |
33 | #include <arch/types.h> |
34 | #include <arch/types.h> |
34 | #include <arch/atomic.h> |
35 | #include <arch/atomic.h> |
35 | #include <debug.h> |
36 | #include <debug.h> |
36 | #include <proc/thread.h> |
37 | #include <proc/thread.h> |
37 | #include <memstr.h> |
38 | #include <memstr.h> |
38 | 39 | ||
39 | #define MAX_FRAMES 128 |
40 | #define MAX_FRAMES 256 |
40 | #define MAX_ORDER 2 |
41 | #define MAX_ORDER 8 |
41 | 42 | ||
42 | #define THREAD_RUNS 1 |
43 | #define THREAD_RUNS 1 |
43 | #define THREADS 6 |
44 | #define THREADS 8 |
44 | 45 | ||
45 | static void thread(void * arg); |
46 | static void thread(void * arg); |
46 | static void failed(void); |
47 | static void failed(void); |
47 | 48 | ||
48 | static atomic_t thread_count; |
49 | static atomic_t thread_count; |
Line 51... | Line 52... | ||
51 | int status, order, run, allocated,i; |
52 | int status, order, run, allocated,i; |
52 | 53 | ||
53 | __u8 val = *((__u8 *) arg); |
54 | __u8 val = *((__u8 *) arg); |
54 | index_t k; |
55 | index_t k; |
55 | 56 | ||
56 | __address frames[MAX_FRAMES]; |
57 | __address * frames = (__address *) malloc(MAX_FRAMES * sizeof(__address)); |
57 | 58 | ||
58 | for (run=0;run<THREAD_RUNS;run++) { |
59 | for (run=0;run<THREAD_RUNS;run++) { |
59 | 60 | ||
60 | for (order=0;order<=MAX_ORDER;order++) { |
61 | for (order=0;order<=MAX_ORDER;order++) { |
61 | printf("Thread #%d: Allocating %d frames blocks ... \n",val, 1<<order); |
62 | printf("Thread #%d: Allocating %d frames blocks ... \n",val, 1<<order); |
62 | allocated = 0; |
63 | allocated = 0; |
63 | for (i=0;i<MAX_FRAMES>>order;i++) { |
64 | for (i=0;i < (MAX_FRAMES >> order);i++) { |
64 | frames[allocated] = frame_alloc(FRAME_NON_BLOCKING | FRAME_KA,order, &status); |
65 | frames[allocated] = frame_alloc(FRAME_NON_BLOCKING | FRAME_KA,order, &status); |
65 | if (status == 0) { |
66 | if (status == 0) { |
66 | memsetb(frames[allocated], (1 << order) * FRAME_SIZE, val); |
67 | memsetb(frames[allocated], (1 << order) * FRAME_SIZE, val); |
67 | allocated++; |
68 | allocated++; |
68 | } else { |
69 | } else { |
Line 72... | Line 73... | ||
72 | 73 | ||
73 | printf("Thread #%d: %d blocks alocated.\n",val, allocated); |
74 | printf("Thread #%d: %d blocks alocated.\n",val, allocated); |
74 | 75 | ||
75 | printf("Thread #%d: Deallocating ... \n", val); |
76 | printf("Thread #%d: Deallocating ... \n", val); |
76 | for (i=0;i<allocated;i++) { |
77 | for (i=0;i<allocated;i++) { |
- | 78 | ||
77 | for (k=0;k<=((FRAME_SIZE << order) - 1);k++) { |
79 | for (k=0;k<=((FRAME_SIZE << order) - 1);k++) { |
78 | if ( ((char *) frames[i])[k] != val ) { |
80 | if ( ((char *) frames[i])[k] != val ) { |
79 | printf("Thread #%d: Unexpected data in block %P offset %X\n",val, frames[i], k); |
81 | printf("Thread #%d: Unexpected data in block %P offset %X\n",val, frames[i], k); |
80 | failed(); |
82 | failed(); |
81 | } |
83 | } |
82 | 84 | ||
83 | } |
85 | } |
84 | 86 | ||
85 | frame_free(frames[i]); |
87 | frame_free(frames[i]); |
86 | } |
88 | } |
87 | printf("Thread #%d: Finished run.\n", val); |
89 | printf("Thread #%d: Finished run.\n", val); |
88 | } |
90 | } |
89 | } |
91 | } |