1285
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include <string.h>
|
|
4 #include "TaskManager.h"
|
|
5 #include "Func.h"
|
|
6
|
|
7 extern void task_init(void);
|
|
8 extern TaskManager *manager;
|
|
9
|
|
10 static long task_num = 10;
|
|
11
|
|
12 /* help文章 */
|
|
13 const char *usr_help_str = "Usage: ./null [-cpu spe_num] [-num N]\n\
|
|
14 -cpu Number of SPE (default 1) \n\
|
|
15 -num Task Num (default 10)";
|
|
16
|
|
17 int
|
|
18 init(int argc, char **argv)
|
|
19 {
|
|
20 for (int i = 1; argv[i]; ++i) {
|
|
21 if (strcmp(argv[i], "-num") == 0) {
|
|
22 task_num = atoi(argv[++i]);
|
|
23 }
|
|
24 }
|
|
25 return 0;
|
|
26 }
|
|
27
|
|
28 void
|
|
29 null_init(TaskManager *manager)
|
|
30 {
|
|
31
|
|
32 // Create Task
|
|
33 for (long i = 0; i < task_num; i++) {
|
|
34 HTask *null = manager->create_task(NullTask);
|
|
35 null->set_cpu(SPE_ANY);
|
|
36 null->spawn();
|
|
37 }
|
|
38
|
|
39 }
|
|
40
|
|
41 int
|
|
42 TMmain(TaskManager *manager, int argc, char *argv[])
|
|
43 {
|
|
44 if (init(argc, argv) < 0) {
|
|
45 return -1;
|
|
46 }
|
|
47
|
|
48 task_init();
|
|
49 null_init(manager);
|
|
50
|
|
51 return 0;
|
|
52 }
|