Ejemplo n.º 1
0
/*
 *  Main function
 */
void main(void) 
{
	TRISB = 0x00;            //configuring all portb bits as outputs
    PORTB = 0;               //force 0 state to all outputs
    
    TRISA = 0xFF;            //configuring all porta bits as inputs
    
    //init displays´ values
    SetValuesDisplays(0,0,0);
    
    //init time counter
    InitTimeCounter();
    
    //init tasks and config Timer0
    InitTasks();   
	ConfigTimer0();
    
	//main loop 
    while(1)                      
    {
        //Verification: check if there´s a task to be executed
        if ((Timer0IntGeneraed == YES)  && (NUMBER_OF_TASKS)) 
        {
            Timer0IntGeneraed = NO;  
            ExecuteTask();			
        }
    }
}
Ejemplo n.º 2
0
void EnqueueTasks(const std::vector<Task *> &tasks) {

	if(CORE_NUM==1){
		numUnfinishedTasks += tasks.size();
		progress_thread = new std::thread(progress);
		for(int i=0;i<tasks.size();++i){
			tasks[i]->Run();
			--numUnfinishedTasks;
		}
		return;
	}

	taskQueueMutex.lock();
	//cout << "EnqueueTasks" << endl;
	for (int i = 0; i < tasks.size(); ++i) {
		taskQueue.push_back(tasks[i]);
	}
	numMaxTasks=taskQueue.size();
	//cout << "EnqueueTasks end" << endl;
	taskQueueMutex.unlock();
	tasksRunningConditionMutex.lock();
	numUnfinishedTasks += tasks.size();
	tasksRunningConditionMutex.unlock();
	if (!threads){
		InitTasks();
		if(!progress_thread)progress_thread = new std::thread(progress);
	}

//	//	progress_thread->detach();
//	for (int i = 0; i < CORE_NUM; ++i) {
//		threads[i]->detach();
//	}
}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------------------------------
 * 函数:    InitFamesOS()
 *
 * 说明:    初始化FamesOS
 *
 * 备注:    下面3个函数都由main()函数调用, 应用程序不可调用
**--------------------------------------------------------------------------------------------*/
void apical InitFamesOS(void)
{
    CALLED_ONLY_ONCE();
    FamesOSStarted=NO;
    InitializeOnExit(); /* should call this before others */
    InitMemService();
    InitIrqManager();
    InitTasks(); 
    InitSwitch();
    InitTimeTick();
    InitApplication();
}
Ejemplo n.º 4
0
/*
 *  Main function
 */
void main(void) 
{
	/*
     * example of input and output configuration. It can be changed according to what you need
     */
    TRISB = 0x00;            //configures all bits of PORTB as outputs
    PORTB = 0;               //sets all portb´s outputs to 0    
    TRISA = 0xFF;            //configures all bits of PORTA as inputs
    
    //init tasks and config Timer0
    InitTasks();   
	ConfigTimer0();
    
	//main loop 
    while(1)                      
    {
        //Verification: check if there´s a task to be executed
        if ((Timer0IntGeneraed == YES)  && (NUMBER_OF_TASKS)) 
        {
            Timer0IntGeneraed = NO;  
            ExecuteTask();			
        }
    }
}
Ejemplo n.º 5
0
int main(int argc, char* argv[])
{	
	int i = 0;
	char symbol;
	int end_app = 0;
	int task = 0;
	int server = msgget(15071410, 0644 | O_EXCL);
	struct msgbuf message;
	struct msgbuf m[20];

	for(i=0; i<20; i++)
	{
		strcpy(m[i].text, "");
		strcpy(m[i].nick, "");
		strcpy(m[i].date, "");
	}

	if (server == -1)
	{
		printf("Blad komunikacji z serwerem! \n");
	}

	InitMenu();

	while(!end_app)
	{
		printf("\nPodaj ID zadania: ");
		scanf("%d",&task);

		switch(task)
		{
			case 1:
				printf("Logowanie. Podaj nick: \n");
				scanf("%s", message.nick);
				break;
			case 2:
				//printf("Uzytkownicy: \n");
				break;
			case 3:
				//printf("Grupy: \n");
				break;
			case 4:
				printf("Zmien nick: \n");
				scanf("%s", message.nick);
				break;
			case 5:
				printf("Dolacz do grupy. Podaj nazwe grupy: \n");
				scanf("%s", message.nick);
				break;
			case 6:
				printf("Wypisz sie z grupy. Podaj nazwe grupy: \n");
				scanf("%s", message.nick);
				break;
			case 8:
				printf("Wyswietl chat. \n ");
				ShowChat(message, m, server);
				break;
			case 9:
				printf("Wyslij wiadomosc do grupy. Podaj nazwe grupy: \n");
				scanf("%s", message.nick);
				
				i=0;
				strcpy(message.text, ""); //clear old msg
				while( (symbol = getchar()) != '\n')
				{
					//clean buffer
				}
                printf("Podaj wiadomosc: \n");
                symbol=getchar();
                while(( (symbol != '\n') && (i <256) )){
                	printf("Moje i to: %d", i);
                    message.text[i++]=symbol;
                    symbol = getchar();
                }
                message.text[i]=0;
				break;
			case 10:
				printf("Wyloguj \n");
				break;
		}
		message = InitTasks(message, task);
		msgsnd(server, &message, sizeof(message), 0);
		msgrcv(server, &message, sizeof(message), getpid(), MSG_NOERROR);
		CheckStatus(message);
		CheckCMD(message);
	}

	return 0;
}