Skip to content

Commit d36aced

Browse files
Update perf_counter.c
1 parent 2d7f024 commit d36aced

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

perf_counter.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,29 +102,34 @@ void perfc_port_clear_system_timer_counter(void);
102102
void perfc_port_insert_to_system_timer_insert_ovf_handler(void)
103103
{
104104
int64_t lLoad = perfc_port_get_system_timer_top() + 1;
105-
s_lSystemClockCounts += lLoad;
106105

107-
// update system ms counter
108-
do {
109-
int64_t lTemp = s_wMSResidule + lLoad;
106+
/* prevent high priority exceptions from preempting the system timer OVF
107+
* exception handling
108+
*/
109+
__IRQ_SAFE {
110+
s_lSystemClockCounts += lLoad;
111+
112+
// update system ms counter
113+
do {
114+
int64_t lTemp = s_wMSResidule + lLoad;
110115

111-
int64_t lMS = lTemp / s_wMSUnit;
112-
s_lSystemMS += lMS;
113-
s_wMSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lMS * s_wMSUnit);
116+
int64_t lMS = lTemp / s_wMSUnit;
117+
s_lSystemMS += lMS;
118+
s_wMSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lMS * s_wMSUnit);
114119

115-
} while(0);
120+
} while(0);
116121

117-
// update system us counter
118-
do {
119-
int64_t lTemp = s_wUSResidule + lLoad;
122+
// update system us counter
123+
do {
124+
int64_t lTemp = s_wUSResidule + lLoad;
120125

121-
int64_t lUS = lTemp / s_wUSUnit;
122-
s_lSystemUS += lUS;
123-
124-
s_wUSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lUS * s_wUSUnit);
126+
int64_t lUS = lTemp / s_wUSUnit;
127+
s_lSystemUS += lUS;
125128

126-
} while(0);
129+
s_wUSResidule = (uint32_t)((int64_t)lTemp - (int64_t)lUS * s_wUSUnit);
127130

131+
} while(0);
132+
}
128133
}
129134

130135
uint32_t perfc_get_systimer_frequency(void)

0 commit comments

Comments
 (0)