364
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
370
|
4 #include <assert.h>
|
|
5 #include <strings.h>
|
364
|
6 #include "TaskManager.h"
|
|
7 #include "Func.h"
|
368
|
8 #include "MemList.h"
|
|
9 #include "MemorySegment.h"
|
364
|
10
|
|
11
|
|
12 const char *usr_help_str = "Usage: ./hello [-cpu spe_num] [-count N]\n\
|
373
|
13 -cpu Number of SPE (default 1) \n \
|
364
|
14 -count Number of task is print \"Hello, World!!\"";
|
|
15
|
395
|
16
|
370
|
17 void
|
400
|
18 test1(TaskManager *manager, MemList* active, MemList* freelist, uint32 size, uint32 count)
|
370
|
19 {
|
|
20 /*!
|
|
21 active からランダムに要素を取り出してそこの size の領域を書き潰す
|
|
22 そこを moveToFirst を繰り返すテスト
|
373
|
23 */
|
370
|
24 for (uint32 i = 0; i < count; i++) {
|
373
|
25 int index = manager->get_random()%count;
|
|
26 MemorySegment* e = active->get(index);
|
|
27 active->moveToFirst(e);
|
|
28 bzero(e->data, size);
|
370
|
29 }
|
373
|
30 printf("test1\n");
|
370
|
31 }
|
364
|
32
|
395
|
33
|
364
|
34 int
|
400
|
35 TMmain(TaskManager *manager, int argc, char *argv[])
|
364
|
36 {
|
366
|
37 uint32 size = 128;
|
373
|
38 uint32 count = 64;
|
|
39
|
619
|
40 MemList* active = manager->createMemList(size, 0);
|
|
41 MemList* freelist = manager->createMemList(size, count);
|
373
|
42
|
366
|
43 // 配列!
|
370
|
44 uint32 i = 0;
|
|
45 for (;; i++) {
|
373
|
46 MemorySegment* m = freelist->poll();
|
|
47 if (m == 0) {
|
|
48 break;
|
|
49 }
|
|
50 active->addFirst(m);
|
370
|
51 }
|
|
52
|
|
53 assert(i==count);
|
|
54 printf("count = %d\n", i);
|
|
55
|
400
|
56 test1(manager, active, freelist, size, count);
|
370
|
57 delete active;
|
|
58 delete freelist;
|
373
|
59
|
366
|
60 return 0;
|
364
|
61 }
|
619
|
62
|
|
63 /* end */
|