1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 5 #include "k_api.h" 6 krhino_tick_proc(void)7void krhino_tick_proc(void) 8 { 9 #if (RHINO_CONFIG_USER_HOOK > 0) 10 krhino_tick_hook(); 11 #endif 12 13 tick_list_update(1); 14 15 #if (RHINO_CONFIG_SCHED_RR > 0) 16 time_slice_update(); 17 #endif 18 } 19 krhino_sys_tick_get(void)20tick_t krhino_sys_tick_get(void) 21 { 22 CPSR_ALLOC(); 23 tick_t tick_tmp; 24 25 RHINO_CPU_INTRPT_DISABLE(); 26 tick_tmp = g_tick_count; 27 RHINO_CPU_INTRPT_ENABLE(); 28 29 return tick_tmp; 30 } 31 krhino_sys_time_get(void)32sys_time_t krhino_sys_time_get(void) 33 { 34 return (sys_time_t)(krhino_sys_tick_get() * 1000 / RHINO_CONFIG_TICKS_PER_SECOND); 35 } 36 krhino_ms_to_ticks(sys_time_t ms)37tick_t krhino_ms_to_ticks(sys_time_t ms) 38 { 39 uint16_t padding; 40 tick_t ticks; 41 42 padding = 1000 / RHINO_CONFIG_TICKS_PER_SECOND; 43 padding = (padding > 0) ? (padding - 1) : 0; 44 45 ticks = ((ms + padding) * RHINO_CONFIG_TICKS_PER_SECOND) / 1000; 46 47 return ticks; 48 } 49 krhino_ticks_to_ms(tick_t ticks)50sys_time_t krhino_ticks_to_ms(tick_t ticks) 51 { 52 uint32_t padding; 53 sys_time_t time; 54 55 padding = RHINO_CONFIG_TICKS_PER_SECOND / 1000; 56 padding = (padding > 0) ? (padding - 1) : 0; 57 58 time = ((ticks + padding) * 1000) / RHINO_CONFIG_TICKS_PER_SECOND; 59 60 return time; 61 } 62 63