Rev 1767 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1767 | Rev 1780 | ||
|---|---|---|---|
| Line 50... | Line 50... | ||
| 50 | static atomic_t thread_count; |
50 | static atomic_t thread_count; |
| 51 | 51 | ||
| 52 | void falloc(void * arg) |
52 | void falloc(void * arg) |
| 53 | { |
53 | { |
| 54 | int order, run, allocated, i; |
54 | int order, run, allocated, i; |
| 55 | __u8 val = THREAD->tid % THREADS; |
55 | uint8_t val = THREAD->tid % THREADS; |
| 56 | index_t k; |
56 | index_t k; |
| 57 | 57 | ||
| 58 | __address * frames = (__address *) malloc(MAX_FRAMES * sizeof(__address), FRAME_ATOMIC); |
58 | uintptr_t * frames = (uintptr_t *) malloc(MAX_FRAMES * sizeof(uintptr_t), FRAME_ATOMIC); |
| 59 | ASSERT(frames != NULL); |
59 | ASSERT(frames != NULL); |
| 60 | 60 | ||
| 61 | thread_detach(THREAD); |
61 | thread_detach(THREAD); |
| 62 | 62 | ||
| 63 | for (run = 0; run < THREAD_RUNS; run++) { |
63 | for (run = 0; run < THREAD_RUNS; run++) { |
| 64 | for (order = 0; order <= MAX_ORDER; order++) { |
64 | for (order = 0; order <= MAX_ORDER; order++) { |
| 65 | printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order); |
65 | printf("Thread #%d (cpu%d): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order); |
| 66 | allocated = 0; |
66 | allocated = 0; |
| 67 | for (i = 0; i < (MAX_FRAMES >> order); i++) { |
67 | for (i = 0; i < (MAX_FRAMES >> order); i++) { |
| 68 | frames[allocated] = (__address)frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
68 | frames[allocated] = (uintptr_t)frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
| 69 | if (frames[allocated]) { |
69 | if (frames[allocated]) { |
| 70 | memsetb(frames[allocated], FRAME_SIZE << order, val); |
70 | memsetb(frames[allocated], FRAME_SIZE << order, val); |
| 71 | allocated++; |
71 | allocated++; |
| 72 | } else { |
72 | } else { |
| 73 | break; |
73 | break; |
| Line 76... | Line 76... | ||
| 76 | printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated); |
76 | printf("Thread #%d (cpu%d): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated); |
| 77 | 77 | ||
| 78 | printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id); |
78 | printf("Thread #%d (cpu%d): Deallocating ... \n", THREAD->tid, CPU->id); |
| 79 | for (i = 0; i < allocated; i++) { |
79 | for (i = 0; i < allocated; i++) { |
| 80 | for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) { |
80 | for (k = 0; k <= ((FRAME_SIZE << order) - 1); k++) { |
| 81 | if (((__u8 *) frames[i])[k] != val) { |
81 | if (((uint8_t *) frames[i])[k] != val) { |
| 82 | printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k); |
82 | printf("Thread #%d (cpu%d): Unexpected data (%d) in block %p offset %#zx\n", THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k); |
| 83 | failed(); |
83 | failed(); |
| 84 | } |
84 | } |
| 85 | } |
85 | } |
| 86 | frame_free(KA2PA(frames[i])); |
86 | frame_free(KA2PA(frames[i])); |