view TaskManager/kernel/main.cc @ 273:3e9c0039e15c

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 04 Jun 2009 00:12:47 +0900
parents f872cc000fe0
children 181f693be3d5
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;
const char *help_str = "\n\
* Cerium program option *\n\
  -help Print this message \n\
  -cpu   Number of CPU (default 1) \n";

extern const char *usr_help_str;

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

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

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

    manager->set_TMend(defaultTMend);

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

    manager->run();

    (manager->tm_end)();

FINISH:
    delete manager;

    return EXIT_SUCCESS;
}