Changeset 683 for trunk/kernel/kern/core.c
- Timestamp:
- Jan 13, 2021, 12:36:17 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/core.c
r669 r683 3 3 * 4 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 * Alain Greiner (2016,2017,2018)5 * Alain Greiner (2016,2017,2018,2019,2020) 6 6 * 7 7 * Copyright (c) UPMC Sorbonne Universites … … 47 47 core->ticks_nr = 0; 48 48 core->usage = 0; 49 core->spurious_irqs = 0;50 49 core->fpu_owner = NULL; 51 50 core->rand_last = hal_time_stamp() & 0xFFF; … … 55 54 56 55 // initialise the alarms lock 57 busylock_init( &core->alarms_lock, LOCK_CORE_ALARMS );56 remote_busylock_init( XPTR( local_cxy , &core->alarms_lock ) , LOCK_CORE_ALARMS ); 58 57 59 58 // initialise the alarms list … … 61 60 } 62 61 63 /////////////////////////////////////// 64 void core_check_alarms( core_t * core ) 62 //////////////////////////////////////////////////////////////////////////////////// 63 // This static function checks the alarms registered in the core, and calls the 64 // relevant alarm handler for all alarms whose time is elapded. 65 // It does not take the lock protecting the alarm list, because it access only 66 // the first alarm in the list, and all modifications in he list are done 67 // the low level access functions called by the handler(s). 68 //////////////////////////////////////////////////////////////////////////////////// 69 static void core_check_alarms( core_t * core ) 65 70 { 66 71 alarm_handler_t * handler; … … 72 77 if( list_is_empty( root ) ) return; 73 78 74 // get pointer on first alarm when list non empty 75 alarm_t * alarm = LIST_FIRST( root , alarm_t , list ); 76 77 // get first alarm date 78 cycle_t alarm_date = alarm->date; 79 80 // get current date 81 cycle_t current_date = hal_get_cycles(); 82 83 if( current_date >= alarm_date ) 79 while( 1 ) 84 80 { 85 // get pointer on registered alarm handler 86 handler = (alarm_handler_t *)alarm->func_ptr; 87 88 // call alarm handler 89 handler( alarm->args_xp ); 81 // get pointer on first alarm 82 alarm_t * alarm = LIST_FIRST( root , alarm_t , list ); 83 84 // get first alarm date 85 cycle_t alarm_date = alarm->date; 86 87 // get current date 88 cycle_t current_date = hal_get_cycles(); 89 90 // call handler if delay elapsed, and retry 91 if( current_date >= alarm_date ) 92 { 93 // get pointer on registered alarm handler 94 handler = (alarm_handler_t *)alarm->func_ptr; 95 96 // call alarm handler 97 handler( alarm->args_xp ); 98 } 99 else // exit loop when first alarm delay not elapsed 100 { 101 break; 102 } 90 103 } 91 104 } // end core_check_alarms() … … 127 140 uint32_t * tm_us ) 128 141 { 129 *tm_s = (core->ticks_nr*CONFIG_SCHED_TICK_MS_PERIOD)/1000; 130 *tm_us = (core->ticks_nr*CONFIG_SCHED_TICK_MS_PERIOD*1000)%1000000; 142 // get number of cycles 143 uint64_t cycles = core->cycles; 144 145 // get number of cycles per second 146 uint32_t cycles_per_second = LOCAL_CLUSTER->sys_clk; 147 148 *tm_s = cycles / cycles_per_second; 149 *tm_us = (cycles * 1000000) % cycles_per_second; 131 150 } 132 151 … … 139 158 ticks = core->ticks_nr++; 140 159 160 // handle alarms 161 core_check_alarms( core ); 162 141 163 // handle scheduler 142 164 if( (ticks % CONFIG_SCHED_TICKS_PER_QUANTUM) == 0 ) sched_yield( "TICK"); 143 144 // handle alarms145 core_check_alarms( core );146 165 } 147 166
Note: See TracChangeset
for help on using the changeset viewer.