Beispiel #1
0
//Execute simulations of all methods
int simulate_all_methods()
{
	int return_val = EXIT_SUCCESS;
	system_settings default_settings;

#if TEST_SJF

	//Test Shortest Job First w/out Preempt
	std::cout << "Creating SJF ProcessManager..." << std::endl;
	ProcessManager sjf_manager(SJF_nopreempt, default_settings);
	return_val = return_val | run_manager(sjf_manager);

#endif

#if TEST_SJF_PREEMPT

	//Test Shortest Job First w/Preempt
	std::cout << "Creating SJF Preemptive ProcessManager..." << std::endl;
	ProcessManager sjf_p_manager(SJF_preempt, default_settings);
	return_val = return_val | run_manager(sjf_p_manager);

#endif

#if TEST_RR

	//Test Round-Robin
	std::cout << "Creating Round Robin ProcessManager..." << std::endl;
	ProcessManager rr_manager(RR_preempt, default_settings);
	return_val = return_val | run_manager(rr_manager);

#endif

#if TEST_PRE_PRI

	//Test Preemptive Priority
	std::cout << "Creating Preemptive Priority ProcessManager..." << std::endl;
	ProcessManager pp_manager(PrePri, default_settings);
	return_val = return_val | run_manager(pp_manager);

#endif

	//Return results
	return return_val;
}
Beispiel #2
0
bool GUI::run()
{
	static int total_time = 0, fps_count = 0, last_fps= 0;
	static int start_time = 0;

	if (start_time == 0)
	{
		start_time = CL_System::get_time();
	}

	CL_GraphicContext gc = app->get_window()->get_gc();

	gc.set_map_mode(CL_MapMode(cl_map_2d_upper_left));

	CL_Draw::gradient_fill(gc, app->get_window()->get_viewport(), CL_Gradient(CL_Colorf(0.4f, 0.4f, 0.4f, 1.0f), CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f)));

	run_manager(gc);

	CL_String fps = cl_format("FPS: %1", last_fps);
	fps_font.draw_text(gc, gc.get_width() - 100 - 2, 24 - 2, fps, CL_Colorf(0.0f, 0.0f, 0.0f, 1.0f));
	fps_font.draw_text(gc, gc.get_width() - 100, 24, fps, CL_Colorf::white);

	fps_font.draw_text(gc, 24, gc.get_height() - 16, "Rendering GUI onto a CL_Texture, then onto the display window.", CL_Colorf(1.0f, 1.0f, 1.0f, 1.0f));

	fps_count++;
	int time = CL_System::get_time();
	total_time += time - start_time;
	start_time = time;
	if(total_time >= 1000)
	{
		last_fps = fps_count;
		total_time -= 1000;
		fps_count = 0;
	}

	balls.Run(gc);

	CL_KeepAlive::process();
	app->get_window()->flip(0);

	return true;
}
Beispiel #3
0
static int manage_package_mode(const std::string &packagename, bool manager,
                               int processor, const CmdArgs &args)
{
    CmdArgs::const_iterator it = args.begin();
    CmdArgs::const_iterator end = args.end();
    bool stop = false;

    if (not init_current_package(packagename, args))
        return EXIT_FAILURE;

    for (; not stop and it != end; ++it) {
        if (*it == "create") {
            vle::utils::Package::package().create();
        } else if (*it == "configure") {
            vle::utils::Package::package().configure();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "build") {
            vle::utils::Package::package().build();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            if (vle::utils::Package::package().isSuccess()) {
                vle::utils::Package::package().install();
                vle::utils::Package::package().wait(std::cerr, std::cerr);
            }
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "test") {
            vle::utils::Package::package().test();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "install") {
            vle::utils::Package::package().install();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "clean") {
            vle::utils::Package::package().clean();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "rclean") {
            vle::utils::Package::removePackageBinary(
                vle::utils::Package::package().name());
        } else if (*it == "package") {
            vle::utils::Package::package().pack();
            vle::utils::Package::package().wait(std::cerr, std::cerr);
            stop = not vle::utils::Package::package().isSuccess();
        } else if (*it == "all") {
            std::cerr << "all is not yet implemented\n";
            stop = true;
        } else if (*it == "depends") {
            std::cerr << "Depends is not yet implemented\n";
            stop = true;
        } else if (*it == "list") {
            show_package_content();
        } else {
            break;
        }
    }

    int ret = EXIT_SUCCESS;

    if (stop)
        ret = EXIT_FAILURE;
    else if (it != end) {
#ifndef NDEBUG
        vle::devs::ExternalEvent::allocated = 0;
        vle::devs::ExternalEvent::deallocated = 0;
        vle::devs::InternalEvent::allocated = 0;
        vle::devs::InternalEvent::deallocated = 0;
        vle::value::Value::allocated = 0;
        vle::value::Value::deallocated = 0;
#endif
        if (manager)
            ret = run_manager(it, end, processor);
        else
            ret = run_simulation(it, end);

#ifndef NDEBUG
        std::cerr << vle::fmt(_("\n - Debug mode:\n"
                    "                       allocated   deallocated\n"
                    "   - External events: %=12d/%=12d\n"
                    "   - Internal events: %=12d/%=12d\n"
                    "   - Values         : %=12d/%=12d\n")) %
            vle::devs::ExternalEvent::allocated %
            vle::devs::ExternalEvent::deallocated %
            vle::devs::InternalEvent::allocated %
            vle::devs::InternalEvent::deallocated %
            vle::value::Value::allocated %
            vle::value::Value::deallocated;
#endif
    }

    return ret;
}