Example #1
0
void inline mainmenu(unsigned char input)
{
    switch(input)
    {
        case 'a':
            scheduler.autoassign();
            state = MAIN;
            break;
        case 'b':
            state = SHIFT;
            break;
        case 'c':
            state = STUDENT;
            break;
        case 'd':
            scheduleToXLS(scheduler,output);
            output.Dump(filepath);
            state = MAIN;
            break;
        case 'z':
            state = EXIT;
            break;
    }

}
Example #2
0
int main(){
	// Initialize the scheduler 
	Scheduler S;

	// Load the job list
	string jobfile;
	cout << "Please input the job file name:";
	cin >> jobfile;
	S.load_jobs(jobfile);

	// Scheduling the jobs
	S.round_robin();

	// Print the results
	S.display();
}
Example #3
0
void Scheduler::_uavcan_thread(void *arg)
{
    Scheduler *sched = (Scheduler *)arg;
    chRegSetThreadName("apm_uavcan");
    while (!sched->_hal_initialized) {
        sched->delay_microseconds(20000);
    }
    while (true) {
        sched->delay_microseconds(100);
        for (int i = 0; i < MAX_NUMBER_OF_CAN_INTERFACES; i++) {
            if(hal.can_mgr[i] != nullptr) {
                CANManager::from(hal.can_mgr[i])->_timer_tick();
            }
        }
    }
}
Example #4
0
// Per OpenVX
// Computes a Gaussian filter over a window of the input image.
// This filter uses the following convolution matrix:
//         1  2  1
//     K = 2  4  2    *  1/16
//         1  2  1
//
// https://www.khronos.org/registry/vx/specs/1.0/html/d6/d58/group__group__vision__function__gaussian__image.html
Halide::Func gaussian_3x3(Halide::Func input, bool grayscale, const Scheduler &s) {
    Halide::Func k, gaussian("gaussian_3x3");
    Halide::RDom r(-1,3,-1,3);
    Halide::Var x,y,xi,yi,c;

    k(x,y) = 0;
    k(-1,-1) = 1;
    k(0,-1) = 2;
    k(1,-1) = 1;
    k(-1, 0) = 2;
    k(0, 0) = 4;
    k(1, 0) = 2;
    k(-1, 1) = 1;
    k(0, 1) = 2;
    k(1, 1) = 1;

    if (grayscale) {
        gaussian(x,y) = sum(input(x+r.x, y+r.y) * k(r.x, r.y)) / 16;
        //gaussian(x,y) /= 16;
    } else {
        gaussian(x,y,c) = sum(input(x+r.x, y+r.y, c) * k(r.x, r.y)) / 16;
        //gaussian(x,y,c) /= 16;
    }

    s.schedule(gaussian, x, y);
    return gaussian;
}
Example #5
0
void
main_shutdown_graceful()
{
	dedicated_scheduler.shutdown_graceful();
	GridUniverseLogic::shutdown_graceful();
	scheduler.shutdown_graceful();
}
        virtual void run(){
            std::cout << "Hello, world!\n" << std::flush;

            // Use Scheduler.delay to stop a execution
            scheduler.delay(1000);
            std::cout << "How are you?\n" << std::flush;
        };
Example #7
0
int main(){
    process_proc_file();
    cout<<"Size of process list  "<<process_list.size()<<"\n";
    //cout<<(process_list[1].phases[1]).io_time<<endl;
    process_scheduler_file();
    //cout<<my_scheduler.levels[1].time_slice<<endl;
    for(int i =0;i<process_list.size();i++){
        Event *e = new Event();
        
        e->eventType = ADMISSION_EVENT;
      //  printf("Admission event type is % d type is %d\n ",ADMISSION_EVENT,e->eventType);
        e->time =process_list[i].admission; 
        Process *p1 = new Process(process_list[i]);
       // std::cout<<" Process with pid" << p1->getPid()<<"\n";
        e->p = p1;
        eventManager.addEvent(e);
    }
    sch.initialize(my_scheduler.levels[0].time_slice);
    cpuStopEvent = new Event();
    cpuStopEvent->time = -1;
    cpuStopEvent->p = NULL;
    cpuStopEvent->eventType= DEFAULT;
    
    eventManager.start();
}
Example #8
0
SocketUtil::~SocketUtil(){
    if (m_bSchedulerBegin) {
        Scheduler* pScheduler = CCDirector::getInstance()->getScheduler();
        pScheduler->unscheduleSelector(schedule_selector(SocketUtil::executeRender), this);
        m_bSchedulerBegin = false;
    }
    if (m_pSendBuf) {
        delete m_pSendBuf;
        m_pSendBuf = nullptr;
    }
    if (m_pRecvBuf) {
        delete m_pRecvBuf;
        m_pRecvBuf = nullptr;
    }
    closeAndDeleteSocket();
}
		void execute(){
			if(jobs.empty()){
				NoJobException exp;
				throw exp;
			}
			current ++;
			current %= jobs.size();
			// did the job
			jobs[current].incCompleted();
			// set the response time
			jobs[current].setResponseTime(scheduler->getCurrentTime() - jobs[current].getArrivalTime());
				
			cout << jobs[current].getName() << "\t";
			// add the wait quantum to everybody other than current
			int size = jobs.size();
			for(int i=0;i<size;++i){
				if(i == current)
					continue;
				jobs[i].wait();				
			}
			
			// if completed tell the RR_Scheduler
			if(jobs[current].isCompleted()){
				JobDoneException exp(jobs[current]);
				removeCurrent();
				if(jobs.size()){
					current += (jobs.size()-1);
					current %= jobs.size();
				}
				throw exp;
			}
		}
Example #10
0
void
main_config()
{
	GridUniverseLogic::reconfig();
	scheduler.reconfig();
	dedicated_scheduler.reconfig();
}
// Tests member api pop
TEST(Scheduler, pop) {

	Scheduler sc;
	sc.start();

	bool ret = sc.add(2, 4083360000);
	EXPECT_TRUE(ret);

	ret = sc.add(0, 4083339999);
	EXPECT_TRUE(ret);

	ret = sc.add(0, 4083329999);
	EXPECT_TRUE(ret);

	sleep(1);

	ret = sc.add(1, 4083349999);
	EXPECT_TRUE(ret);

	ret = sc.add(2, 4083369999);
	EXPECT_TRUE(ret);

	ret = sc.add(1, 4083359999);
	EXPECT_TRUE(ret);

	ret = sc.add(0, 4083350000);
	EXPECT_TRUE(ret);

	cout << sc << endl;

	sleep(1);
  // <TechnicalDetails>
  //
  // EXPECT_EQ(expected, actual) is the same as
  //
  //   EXPECT_TRUE((expected) == (actual))

  // <TechnicalDetails>
  //
  // EXPECT_EQ(expected, actual) is the same as
  //
  //   EXPECT_TRUE((expected) == (actual))
  //
  // except that it will print both the expected value and the actual
  // value when the assertion fails.  This is very helpful for
  // debugging.  Therefore in this case EXPECT_EQ is preferred.
  //
  // On the other hand, EXPECT_TRUE accepts any Boolean expression,
  // and is thus more general.
  //
  // </TechnicalDetails>
}
Example #12
0
void FGgameinit::copyFileUpdate(float dt)
{
    
//#ifdef GameNeedUpdate
    if(copyfileName.size()>0)
    {

        string tempName = copyfileName[copyfileName.size()-1];
        if( copyfileAndUnzip(tempName.c_str()))
        {
            copyfileName.pop_back();
        }
    }else if (copyfileName.size()==0)
    {
        FGgameSet::getInstance()->setIntegerForKey("luaIsCopy",1);
        FGgameSet::getInstance()->flush();
        
    }
//#else
//    FGgameSet::getInstance()->setIntegerForKey("luaIsCopy",1);
//    FGgameSet::getInstance()->flush();
//#endif
    
    
    int nowluaisCopy= FGgameSet::getInstance()->getIntegerForKey("luaIsCopy");
    //拷贝完成 开始其他初始化
    if(nowluaisCopy==1)
    {
        string nowGameVersion = FGUpdateModule::SharedIntance()->requestGameVersion();
        FGgameSet::getInstance()->setStringForKey("gameVersion",nowGameVersion);
        FGgameSet::getInstance()->flush();
//        log("WTF__gameversion写入_%s",nowGameVersion.c_str());
        
        Director *pDirector = Director::getInstance();
        Scheduler *pCcscheduler = pDirector->getScheduler();
        pCcscheduler->unschedule(schedule_selector(FGgameinit::copyFileUpdate), this);
    
        Function.clear();
        Function.push_back(callfunc_selector(FGgameinit::initImageResources));
        //Function.push_back(callfunc_selector(FGgameinit::initSounResources));
        pCcscheduler->schedule(schedule_selector(FGgameinit::initResourcesUpdate), this,0.001,false);
        
        //渲染特效
        FGgameinit::SharedIntance()->showEffect();
    }
    
}
Example #13
0
void test_scheduler() {
	Scheduler sch;
	// Initialize a queue of
	PCB pcb[5];

	for (int i=0; i < 5; i++)
		sch.sm.new_state.push_back(pcb[i]);

	cout << "Initial PCBs in new state: " << sch.get_new_state().size()<<endl;
	iterate_state(sch.get_new_state());

	// Move the first PCB from the new state and add it to the ready state
//	it = sm.new_state.begin();
//	sm.new_state.splice(it, sm.ready_state);
//	sm.ready_state.splice(sm.ready_state.begin(), sm.new_state, it);

//	sch.sm.new_to_ready();
//	sch.dispatch();
//	sch.dispatch();
//	sch.sm.new_to_ready();

//	cout << "PCBs in new state" <<endl;
//	iterate_state(sch.get_new_state());
//
//	cout << "PCBs in ready state" <<endl;
//	iterate_state(sch.get_ready_state());
//
//	cout << "Process state is: " << sch.get_ready_state().front().get_state()<<endl;
//	sch.dispatch();
//	cout << "Run state: " << sch.get_run_state().get_state()<<endl;
//	sch.terminate();
//	cout << "Runtime: " << sch.get_runtime()<<endl;
//	iterate_state(sch.get_exit_state());


//	cout << sch.get_ram()<<endl;
	sch.admit();
	sch.admit();
	sch.admit();
	cout << "Ready State"<<endl;
	iterate_state(sch.get_ready_state());
	sch.dispatch();
	cout << "Run State"<<endl;
	cout << sch.get_run_state().get_pid()<<endl;
	sch.terminate();
	cout << sch.get_run_state().get_pid()<<endl;
};
Example #14
0
NPC::NPC(ScriptEngine& engine, Scheduler& scheduler, const std::string& name, const std::string& sheetName,
		messaging::MessagePipe& messagePipe, EntityGrid& entityGrid, const std::string& regionName, const shapes::Point2D& location, const shapes::Size& size)
   : Actor(name, sheetName, messagePipe, entityGrid, location, size, 0.1f, DOWN)
{
   npcThread = engine.getNPCScript(this, regionName, entityGrid.getMapData()->getName(), name);
   scheduler.start(npcThread);
   DEBUG("NPC %s has a Thread with ID %d", name.c_str(), npcThread->getId());
}
void refreshGas() {
    int valueSmoke = read_gas_sensor();
    if (valueSmoke == 48) {
         printf ("Gas presence \n");
         sendEdisonPackage(1);
    }
    scheduler.schedule(refreshGas, REFRESH_GAS_MS);
}
Example #16
0
Hero::Hero() :
_body(nullptr),
_eventListenerCustom(nullptr),
_velocity(0),
_maxVelocity(3),
_speed(0.72),
_gravity(0),
_jumpPower(7.0f),
_jumpHeight(0.0f),
_animeSwitch(false),
_state(NORMAL),
_prevState(NORMAL)
{
    Director* director = Director::getInstance();
    Scheduler *scheduler = director->getScheduler();
    scheduler->schedule(schedule_selector(Hero::update), this, 0, false);
}
Example #17
0
int main(int ac, char *av[])
{
	// Lire fichier de conf
	// Générer les checks
	//   -> ip, port à tester
	//   -> Action à effectuer
	//   -> Durée entre chaque check
	// Scheduler
	//   -> loop sur les taches a effectuer
	//       -> si temps est dépassé -> on lance le check et on met à jour le (next) timestamp
	Checker c("127.0.0.1", 80,	"echo toto", 10);
	Scheduler s;
	s.pushChecker(c);
	s.pushChecker(Checker("127.0.0.1", 443, "echo tutu", 21));
	s.run();
	system("PAUSE");
}
bool TSimpleGestureRecognizer::onTouchBegan(Touch* touch, Event* event)
{
    if (_finger0 == NULL)
    {
        _finger0 = touch;
        _finger0->retain();
        
        _finger0StartPt = _finger0->getLocation();
        _finger0PrevPt = _finger0StartPt;
        _finger0Pt = _finger0StartPt;
        _finger0Moved = false;
        
        _finger0StartTime = getCurrentTime();
        _finger0Time = _finger0StartTime;
        
        // Tap/double tap initialization
        _tapValid = true;
        
        // Long press recognition is applied on 1st finger only
        _longPressActivatingScheduled = false;
        if (_longPressEnabled && !_finger1)
        {
            Scheduler* scheduler = Director::getInstance()->getScheduler();
            scheduler->unschedule(schedule_selector(TSimpleGestureRecognizer::onLongPressActivate), this);
            scheduler->schedule(schedule_selector(TSimpleGestureRecognizer::onLongPressActivate), this, 0, 0, _longPressThreshold, false);
            
            _longPressActivatingScheduled = true;
        }
    }
    else if (_finger1 == NULL)
    {
        _finger1 = touch;
        _finger1->retain();
        
        _finger1StartPt = _finger1->getLocation();
        _finger1PrevPt = _finger1StartPt;
        _finger1Pt = _finger1StartPt;
        _finger1Moved = false;
    }
    else
    {
        CCLOG("TouchBegan: More than 2 fingers are used - Ignored");
    }
    
    return false;
}
inline void
CertificateCacheTtl::removeAll()
{
  for(Cache::iterator it = m_cache.begin(); it != m_cache.end(); it++)
    m_scheduler.cancelEvent(it->second.second);

  m_cache.clear();
}
Example #20
0
void FGgameinit::initStartGameviewGeneral()
{
    //TDGameAnalytics
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    //TDCCTalkingDataGA::onStart("FAF47ACC72DD5FCC7D076347A1CEACE9", FGMarketGetMarketName(SHARED_MARKET_API->getMarketCid()));
//    if(SHARED_MARKET_API->getMarketCid()==100)
//    {
//        FGappcpaInit();
//        
//    }
#endif
    
    LabelTitle = Label::createWithSystemFont(NSLocalizedString("游戏初始化中...","游戏启动"), "Helvetica", 40);
    LabelTitle->setColor(Color3B::WHITE);
    LabelTitle->setPosition(Vec2 ( VisibleRect::center().x,100));
    
    
    CreateBgInit();
    
    globalScene->addChild(LabelTitle);
    
//    ShowGameVersion();
    
    //TODO 暂不拷贝lua
    /*
    int luaisCopy= FGgameSet::getInstance()->getIntegerForKey("luaIsCopy");
    copyfileName.clear();
    if(luaisCopy!=1)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
        //        copyfileName.push_back("allLua.zip");
        copyfileName.push_back("floragameRes_android_1.zip");
#else
        
#ifdef GameNeedUpdate
        copyfileName.push_back("allLua.zip");
#endif
        
#endif
    }
     */
    
    Director *pDirector = Director::getInstance();
    Scheduler *pCcscheduler = pDirector->getScheduler();
    pCcscheduler->schedule(schedule_selector(FGgameinit::copyFileUpdate), this, 0.001, false);
}
Example #21
0
 Listener::Listener(Scheduler &scheduler)
     : m_scheduler(&scheduler)
     , m_acceptor(scheduler.asio())
     , m_next_connection(scheduler)
 {
     set_connection_handler(nullptr);
     set_error_handler(nullptr);
 }
Example #22
0
void OccasionalChain::run(Scheduler &sched) {
    int delayMs;
    
    switch (mState) {
        case 0:
            delayMs = mUniformDistribution(mRng) * 1000;
            mState = 1;
            sched.scheduleDelayedExecutionRelative(*this, delayMs);
            break;
        case 1:
            playback_command_t* cmd = (playback_command_t*) malloc(sizeof(playback_command_t));
            sendCommand(cmd);
            mState = 0;
            sched.scheduleDelayedExecutionRelative(*this, 0);
            break;
    }
}
Example #23
0
int main()
{
   Scheduler sched;		    // make a process scheduler
   Process tasks[] = 		    // 3 processes
	{ Process(0), Process(1), Process(2) };	
   int arrival[] = {0, 40, 80};   // arrive at these times
 
   cout << "First Come First Served" << endl;
   sched.runScheduler( tasks, arrival, 3, 500000 );	// FIFO
   displayHistory( tasks, 3, 0, 500 );
   cout << endl << "Quanta of 70" << endl;
   sched.runScheduler( tasks, arrival, 3, 70 );	// RR generous
   displayHistory( tasks, 3, 0, 500 );
   cout << endl << "Quanta of 10" << endl;
   sched.runScheduler( tasks, arrival, 3, 10 );	// RR stingy
   displayHistory( tasks, 3, 0, 500 );
}
/* ************************************************************************* */
void addStudent(Scheduler& s, size_t i) {
  switch (i) {
  case 0:
    s.addStudent("Michael N", "AI", "Autonomy", "Perception", "Tucker Balch");
    break;
  case 1:
    s.addStudent("Tucker H", "Controls", "AI", "Perception", "Jim Rehg");
    break;
  case 2:
    s.addStudent("Jake H", "Controls", "AI", "Perception", "Henrik Christensen");
    break;
  case 3:
    s.addStudent("Tobias K", "Controls", "AI", "Autonomy", "Mike Stilman");
    break;
  case 4:
    s.addStudent("Shu J", "Controls", "AI", "HRI", "N/A 1");
    break;
  case 5:
    s.addStudent("Akansel C", "AI", "Autonomy", "Mechanics",
        "Henrik Christensen");
    break;
  case 6:
    s.addStudent("Tiffany C", "Controls", "N/A 1", "N/A 2", "Charlie Kemp");
    break;
  }
}
/* ************************************************************************* */
void runLargeExample() {

  Scheduler scheduler = largeExample();
  scheduler.print();

  // BUILD THE GRAPH !
  size_t addMutex = 2;
  scheduler.buildGraph(addMutex);

  // Do brute force product and output that to file
  if (scheduler.nrStudents() == 1) { // otherwise too slow
    DecisionTreeFactor product = scheduler.product();
    product.dot("scheduling-large", false);
  }

  // Do exact inference
  //  SETDEBUG("timing-verbose", true);
  SETDEBUG("DiscreteConditional::DiscreteConditional", true);
  gttic(large);
  DiscreteFactor::sharedValues MPE = scheduler.optimalAssignment();
  gttoc(large);
  tictoc_finishedIteration();
  tictoc_print();
  scheduler.printAssignment(MPE);
}
Example #26
0
void dodGame::LoadGame()
{
	scheduler.LOAD();
	viewer.setVidInv((game.LEVEL % 2) ?true: false);
	--viewer.UPDATE;
	viewer.draw_game();
	INIVU();
	viewer.PROMPT();
}
inline void
CertificateCacheTtl::insert(shared_ptr<const IdentityCertificate> certificate)
{
  time::milliseconds expire = (certificate->getFreshnessPeriod() >= time::seconds::zero() ?
                               certificate->getFreshnessPeriod() : m_defaultTtl);

  Name index = certificate->getName().getPrefix(-1);

  Cache::iterator it = m_cache.find(index);
  if (it != m_cache.end())
    m_scheduler.cancelEvent(it->second.second);

  EventId eventId = m_scheduler.scheduleEvent(expire,
                                              bind(&CertificateCacheTtl::remove,
                                                   this, certificate->getName()));

  m_cache[index] = std::make_pair(certificate, eventId);
}
Example #28
0
void PooledWorker::Work() {
	g_Logs.server->info("Starting pooled thread worker %v", mWorkerID);
	while(true) {
		g_Logs.server->debug("Waiting for work on thread %v", mWorkerID);
		TaskType t = g_Scheduler.PopPoolTask();
		t();
		PLATFORM_SLEEP(g_MainSleep);
	}
}
Example #29
0
void Scheduler::_timer_thread(void *arg)
{
    Scheduler *sched = (Scheduler *)arg;
    chRegSetThreadName("apm_timer");

    while (!sched->_hal_initialized) {
        sched->delay_microseconds(1000);
    }
    while (true) {
        sched->delay_microseconds(1000);

        // run registered timers
        sched->_run_timers();

        // process any pending RC output requests
        hal.rcout->timer_tick();
    }
}
Example #30
0
int luaEnvironment::add(lua_State *L)
{
    void *ud;
    if( isudatatype(L, -1, "TeTimer") )
    {
        pair<Event,Scheduler>  timeSchedulerPair;
        Scheduler* pTimer = Luna<luaTimer>::check(L, -1);

        timeSchedulerPair.first = pTimer->getEvent();
        timeSchedulerPair.second = *pTimer;

        Environment::add( timeSchedulerPair );
    }
    else
        if( isudatatype(L, -1, "TeCellularSpace") )
        {
            CellularSpace* pCS = Luna<luaCellularSpace>::check(L, -1);
            Environment::add( *pCS);
        }
        else
            if( isudatatype(L, -1,"TeLocalAutomaton") )
            {
                LocalAgent* pAg = Luna<luaLocalAgent>::check(L, -1);
                Environment::add( *pAg);
            }
            else
                if( isudatatype(L, -1, "TeGlobalAutomaton") )
                {
                    GlobalAgent* pAg = Luna<luaGlobalAgent>::check(L, -1);
                    Environment::add( *pAg);
                }
                else
                    if( (ud = luaL_checkudata(L, -1, "TeScale")) != NULL )
                    {
                        pair<Event,Environment>  timeEnvPair;
                        Environment* pEnv = Luna<luaEnvironment>::check(L, -1);

                        timeEnvPair.first = pEnv->getEvent();
                        timeEnvPair.second = *pEnv;

                        Environment::add( timeEnvPair );
                    }
    return 0;
}