Changeset 19 for trunk/kernel/kern/core.c
- Timestamp:
- Jun 3, 2017, 4:46:59 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/core.c
r14 r19 1 1 /* 2 2 * core.c - core descriptor access function. 3 * 3 * 4 4 * Author Ghassan Almaless (2008,2009,2010,2011,2012) 5 5 * Mohamed Lamine Karaoui (2015) … … 41 41 42 42 ///////////////////////////////// 43 void core_init( core_t * core, 44 lid_t lid, 43 void core_init( core_t * core, 44 lid_t lid, 45 45 gid_t gid ) 46 46 { … … 53 53 core->usage = 0; 54 54 core->spurious_irqs = 0; 55 55 core->rpc_threads = 0; 56 56 57 57 rpc_fifo_init( &core->rpc_fifo ); 58 58 59 60 61 62 63 59 list_root_init( &core->rpc_free_list ); 60 61 core->thread_rpc = NULL; 62 core->thread_idle = NULL; 63 core->fpu_owner = NULL; 64 64 core->rand_last = hal_time_stamp() & 0xFFF; 65 65 … … 70 70 inline uint32_t core_get_rand( core_t * core ) 71 71 { 72 73 74 75 72 uint32_t value = ((core->rand_last * CONFIG_RDNG_PARAM_A) + 73 CONFIG_RDNG_PARAM_C) ^ (hal_time_stamp() & 0xFFF); 74 core->rand_last = value; 75 return value; 76 76 } 77 77 … … 79 79 inline uint64_t core_get_cycles( core_t * core ) 80 80 { 81 82 81 uint32_t elapsed; 82 uint64_t cycles; 83 83 uint32_t time_stamp = core->time_stamp; 84 84 uint32_t time_now = hal_time_stamp(); 85 85 86 86 // compute number of elapsed cycles, taking into account 32 bits register wrap 87 87 if(time_now < time_stamp) elapsed = (0xFFFFFFFF - time_stamp) + time_now; 88 88 else elapsed = (time_now - time_stamp); 89 89 90 91 92 93 94 90 cycles = core->cycles + elapsed; 91 92 // update core time 93 core->time_stamp = time_now; 94 core->cycles = cycles; 95 95 hal_wbflush(); 96 96 … … 100 100 //////////////////////////////////// 101 101 void core_get_time( core_t * core, 102 uint32_t * tm_ms, 102 uint32_t * tm_ms, 103 103 uint32_t * tm_us ) 104 104 { 105 105 // uint64_t cycles = core_get_cycles( core ); 106 106 107 107 // TODO ces deux ligne ne compilent pas : "undefined referenc to __udivdi3" 108 108 109 109 // *tm_ms = (cycles / CONFIG_CYCLES_PER_MS); 110 110 // *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000); 111 111 112 112 printk("\n[PANIC] in %s : not implemented yet\n", __FUNCTION__ ); 113 113 } 114 114 … … 116 116 void core_time_update( core_t * core ) 117 117 { 118 118 uint32_t elapsed; 119 119 uint32_t ticks_nr = core->ticks_nr; 120 120 uint64_t cycles = core->cycles; … … 122 122 uint32_t time_now = hal_time_stamp(); 123 123 124 // compute number of elapsed cycles taking into account 32 bits register wrap 124 // compute number of elapsed cycles taking into account 32 bits register wrap 125 125 if( time_now < time_stamp ) elapsed = (0xFFFFFFFF - time_stamp) + time_now; 126 126 else elapsed = time_now - time_stamp; 127 127 128 128 cycles += elapsed; 129 129 ticks_nr = elapsed / core->ticks_period; … … 140 140 uint32_t ticks; 141 141 142 142 // update cycles and ticks counter 143 143 core_time_update( core ); 144 144 145 145 // get current ticks number 146 146 ticks = core->ticks_nr; 147 147 148 148 // handle pending alarms TODO ??? [AG] 149 149 // alarm_clock( &core->alarm_mgr , ticks ); 150 150 151 152 153 154 155 151 // handle scheduler TODO improve the scheduling condition ... AG 152 if( (ticks % 10) == 0 ) sched_yield(); 153 154 // update DQDT TODO This update should depend on the cluster identifier, 155 // to avoid simultaneous updates from various clusters ... AG 156 156 if( ((ticks % CONFIG_DQDT_PERIOD) == 0) && (core->lid == 0) ) dqdt_global_update(); 157 157 } 158 158 159 159 //////////////////////////////////////// 160 void core_compute_stats( core_t * core ) 160 void core_compute_stats( core_t * core ) 161 161 { 162 162 thread_t * idle = core->thread_idle; … … 167 167 uint32_t usage; 168 168 169 // compute cumulated usage 169 // compute cumulated usage 170 170 ticks = (ticks) ? ticks : 1; 171 171 idle_percent = (idle->ticks_nr * 100) / ticks; … … 174 174 usage = (busy_percent + core->usage) / 2; 175 175 176 176 // update core descriptor 177 177 core->usage = usage; 178 178 hal_wbflush(); … … 204 204 chdev_t * chdev ) 205 205 { 206 207 208 209 } 206 if ( irq_type == WTI_TYPE ) core->wti_vector[irq_id] = chdev; 207 else if( irq_type == HWI_TYPE ) core->hwi_vector[irq_id] = chdev; 208 else core->pti_vector[irq_id] = chdev; 209 }
Note: See TracChangeset
for help on using the changeset viewer.