view TaskManager/kernel/main.cc @ 242:8382f0f8c0b4

dma_wait
author e065746@localhost.localdomain
date Sun, 31 May 2009 15:55:00 +0900
parents 894675539cbf
children 1d8b8a4ac453 bbc2375153d7
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;
}