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_Chrono(long t) { RTIME OneUnit = nano2count(ONE_UNIT); MenageHmsh_tHour times; MenageHmsh_tChain11 timesChain; BOOLEAN Intermediatetimes = FALSE; MenageHmsh_tHour endIntermediateTimes; BOOLEAN display; BOOLEAN hundredthes = FALSE; char command; unsigned long msg; rt_receive(&read, &msg); command = 'R'; while(1) { cpu_used[hard_cpu_id()]++; switch(command) { case 'R': MenageHmsh_Initialise(×); display = TRUE; hundredthes = FALSE; Intermediatetimes = FALSE; break; case 'C': rt_fractionated_sleep(OneUnit); MenageHmsh_PlusOneUnit(×, &display); if (Intermediatetimes) { Intermediatetimes = !MenageHmsh_Equal( times, endIntermediateTimes); display = !Intermediatetimes; hundredthes = FALSE; } break; case 'I': Intermediatetimes = TRUE; endIntermediateTimes = times; MenageHmsh_PlusNSeconds(3, &endIntermediateTimes); display = TRUE; hundredthes = TRUE; break; case 'E': display = TRUE; hundredthes = TRUE; } if (display) { MenageHmsh_Convert(times, hundredthes, ×Chain); Display_PutTimes(timesChain); } CommandChrono_Get(&command); } }
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); } } }
void *ClockChrono_Chrono(void *args) { RT_TASK *mytask /*, *keybrd */; MenageHmsh_tHour times; MenageHmsh_tChain11 timesChain; BOOLEAN Intermediatetimes = FALSE; MenageHmsh_tHour endIntermediateTimes; BOOLEAN display; BOOLEAN hundredthes = FALSE; char command; if (!(mytask = rt_thread_init(nam2num("CHRONO"), 1, 0, SCHED_FIFO, 0xF))) { printf("CANNOT INIT TASK ClockChronoChrono\n"); exit(1); } printf("INIT TASK ClockChronoChrono %p.\n", mytask); mlockall(MCL_CURRENT | MCL_FUTURE); rt_make_hard_real_time(); sem_wait(&sync_sem); command = 'R'; while(1) { switch(command) { case 'R': MenageHmsh_Initialise(×); display = TRUE; hundredthes = FALSE; Intermediatetimes = FALSE; break; case 'C': rt_fractionated_sleep(OneUnit); MenageHmsh_PlusOneUnit(×, &display); if (Intermediatetimes) { Intermediatetimes = !MenageHmsh_Equal( times, endIntermediateTimes); display = !Intermediatetimes; hundredthes = FALSE; } break; case 'I': Intermediatetimes = TRUE; endIntermediateTimes = times; MenageHmsh_PlusNSeconds(3, &endIntermediateTimes); display = TRUE; hundredthes = TRUE; break; case 'E': display = TRUE; hundredthes = TRUE; break; case 'F': goto end; } if (display) { MenageHmsh_Convert(times, hundredthes, ×Chain); Display_PutTimes(timesChain); } CommandChrono_Get(&command); } end: rt_make_soft_real_time(); rt_task_delete(mytask); printf("END TASK ClockChronoChrono %p.\n", mytask); return 0; }