Changeset d9dda26 in mainline
- Timestamp:
- 2022-08-15T13:33:01Z (2 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 742f95ec
- Parents:
- 0d59ea7e
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 13:31:57)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 13:33:01)
- Location:
- kernel/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/cpu.h
r0d59ea7e rd9dda26 74 74 size_t missed_clock_ticks; 75 75 76 uint64_t current_clock_tick; 77 76 78 /** 77 79 * Processor cycle accounting. -
kernel/generic/src/time/clock.c
r0d59ea7e rd9dda26 65 65 static parea_t clock_parea; 66 66 67 /** Fragment of second68 *69 * For updating seconds correctly.70 *71 */72 static sysarg_t secfrag = 0;73 74 67 /** Initialize realtime clock counter 75 68 * … … 109 102 * 110 103 * Update it only on first processor 111 * TODO: Do we really need so many write barriers? 112 * 113 */ 114 static void clock_update_counters(void) 104 */ 105 static void clock_update_counters(uint64_t current_tick) 115 106 { 116 107 if (CPU->id == 0) { 117 secfrag += 1000000 / HZ;118 if (secfrag >= 1000000) { 119 secfrag -=1000000;120 uptime->seconds1++;121 write_barrier(); 122 uptime->useconds = secfrag;123 124 uptime->seconds2 = uptime->seconds1;125 } else126 uptime->useconds += 1000000 / HZ;108 uint64_t usec = (1000000 / HZ) * current_tick; 109 110 sysarg_t secs = usec / 1000000; 111 sysarg_t usecs = usec % 1000000; 112 113 uptime->seconds1 = secs; 114 write_barrier(); 115 uptime->useconds = usecs; 116 write_barrier(); 117 uptime->seconds2 = secs; 127 118 } 128 119 } … … 147 138 { 148 139 size_t missed_clock_ticks = CPU->missed_clock_ticks; 140 CPU->current_clock_tick += missed_clock_ticks + 1; 141 uint64_t current_clock_tick = CPU->current_clock_tick; 142 clock_update_counters(current_clock_tick); 149 143 150 144 /* Account CPU usage */ … … 159 153 for (i = 0; i <= missed_clock_ticks; i++) { 160 154 /* Update counters and accounting */ 161 clock_update_counters(); 155 162 156 cpu_update_accounting(); 163 157
Note:
See TracChangeset
for help on using the changeset viewer.