view TaskManager/kernel/main.cc @ 247:0098b5ff0d11

change example
author aaa
date Mon, 01 Jun 2009 19:33:09 +0900
parents 894675539cbf
children 8382f0f8c0b4 f0e800bb9dcc
line wrap: on
line source

#include <stdlib.h>
#include <string.h>
#include <SDL.h>
#include "TaskManager.h"

/* User main function */
extern int TMmain(int argc, char *argv[]);

/* Default TMend function */
static void
defaultTMend(void) {}

TaskManager *manager;
static char *help_str = "\n\
* Cerium program option *\n\
  -chelp Print this message \n\
  -cpu   Number of CPU (default 1) \n";

int
main(int argc, char *argv[])
{
    int cpuNum = 1;

    for (int i = 1; argv[i]; ++i) {
        if (strcmp(argv[i], "-cpu") == 0) {
            cpuNum = atoi(argv[++i]);
        }
        if (strcmp(argv[i], "-chelp") == 0) {
	    printf("%s\n", help_str);
	    return EXIT_SUCCESS;
        }
    }

    manager = new TaskManager(cpuNum);
    manager->init();

    manager->set_TMend(defaultTMend);

    if (TMmain(argc, argv) < 0) {
	goto FINISH;
    }

    manager->run();

    (manager->tm_end)();

FINISH:
    delete manager;

    return EXIT_SUCCESS;
}