void *ClockChrono_Clock(void *args) { RT_TASK *mytask; const int hundredthes = FALSE; MenageHmsh_tHour hour; MenageHmsh_tChain11 hourChain; char command; BOOLEAN display; if (!(mytask = rt_thread_init(nam2num("CLOCK"), 1, 0, SCHED_FIFO, 0xF))) { printf("CANNOT INIT TASK ClockChronoClock\n"); exit(1); } printf("INIT TASK ClockChronoClock %p.\n", mytask); mlockall(MCL_CURRENT | MCL_FUTURE); rt_make_hard_real_time(); sem_wait(&sync_sem); MenageHmsh_Initialise(&hour); while(1) { CommandClock_Get(&command); switch(command) { case 'R': rt_fractionated_sleep(OneUnit); MenageHmsh_PlusOneUnit(&hour, &display); break; case 'T': MenageHmsh_InitialiseHundredthes(&hour); display = FALSE; break; case 'H': MenageHmsh_AdvanceHours(&hour); display = TRUE; break; case 'M': MenageHmsh_AdvanceMinutes(&hour); display = TRUE; break; case 'S': MenageHmsh_AdvanceSeconds(&hour); display = TRUE; break; case 'F': goto end; } if (display) { MenageHmsh_Convert(hour, hundredthes, &hourChain); Display_PutHour(hourChain); } } end: rt_make_soft_real_time(); hourChain.chain[1] = 'e'; Display_PutHour(hourChain); rt_task_delete(mytask); printf("END TASK ClockChronoClock %p.\n", mytask); return 0; }
static void ClockChrono_Clock(long t) { RTIME OneUnit = nano2count(ONE_UNIT); const int hundredthes = FALSE; MenageHmsh_tHour hour; MenageHmsh_tChain11 hourChain; char command; BOOLEAN display; unsigned long msg; rt_receive(&read, &msg); MenageHmsh_Initialise(&hour); MenageHmsh_Convert(hour, hundredthes, &hourChain); Display_PutHour(hourChain); while(1) { cpu_used[hard_cpu_id()]++; CommandClock_Get(&command); switch(command) { case 'R': rt_fractionated_sleep(OneUnit); MenageHmsh_PlusOneUnit(&hour, &display); break; case 'T': MenageHmsh_InitialiseHundredthes(&hour); display = FALSE; break; case 'H': MenageHmsh_AdvanceHours(&hour); display = TRUE; break; case 'M': MenageHmsh_AdvanceMinutes(&hour); display = TRUE; break; case 'S': MenageHmsh_AdvanceSeconds(&hour); display = TRUE; } if (display) { MenageHmsh_Convert(hour, hundredthes, &hourChain); Display_PutHour(hourChain); } } }
static void ClockChrono_Clock(long t) { const int hundredthes = FALSE; MenageHmsh_tHour hour; MenageHmsh_tChain11 hourChain; char command; BOOLEAN display; rt_sem_wait(&sync); MenageHmsh_Initialise(&hour); /* MenageHmsh_Convert(hour, hundredthes, &hourChain); Display_PutHour(hourChain); */ while(1) { cpu_used[hard_cpu_id()]++; CommandClock_Get(&command); switch(command) { case 'R': rt_fractionated_sleep(OneUnit); MenageHmsh_PlusOneUnit(&hour, &display); break; case 'T': MenageHmsh_InitialiseHundredthes(&hour); display = FALSE; break; case 'H': MenageHmsh_AdvanceHours(&hour); display = TRUE; break; case 'M': MenageHmsh_AdvanceMinutes(&hour); display = TRUE; break; case 'S': MenageHmsh_AdvanceSeconds(&hour); display = TRUE; } if (display) { MenageHmsh_Convert(hour, hundredthes, &hourChain); Display_PutHour(hourChain); } } }