Mercurial > hg > Game > Cerium
diff example/Null/main.cc @ 1285:e38a4f3e238d draft
add NullTask
author | Daichi Toma <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 29 Nov 2011 16:20:46 +0900 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/Null/main.cc Tue Nov 29 16:20:46 2011 +0900 @@ -0,0 +1,52 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "TaskManager.h" +#include "Func.h" + +extern void task_init(void); +extern TaskManager *manager; + +static long task_num = 10; + +/* help文章 */ +const char *usr_help_str = "Usage: ./null [-cpu spe_num] [-num N]\n\ + -cpu Number of SPE (default 1) \n\ + -num Task Num (default 10)"; + + int +init(int argc, char **argv) +{ + for (int i = 1; argv[i]; ++i) { + if (strcmp(argv[i], "-num") == 0) { + task_num = atoi(argv[++i]); + } + } + return 0; +} + + void +null_init(TaskManager *manager) +{ + + // Create Task + for (long i = 0; i < task_num; i++) { + HTask *null = manager->create_task(NullTask); + null->set_cpu(SPE_ANY); + null->spawn(); + } + +} + + int +TMmain(TaskManager *manager, int argc, char *argv[]) +{ + if (init(argc, argv) < 0) { + return -1; + } + + task_init(); + null_init(manager); + + return 0; +}