Skip to content

Commit 813eff4

Browse files
committed
Try to fix scheduling sync
1 parent 752fcc2 commit 813eff4

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Sensors/SMCSuperIO/SMCSuperIO.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,11 @@ bool ADDPR(debugEnabled) = false;
2323
uint32_t ADDPR(debugPrintDelay) = 0;
2424

2525
void SMCSuperIO::timerCallback() {
26-
auto time = getCurrentTimeNs();
27-
auto timerDelta = time - timerEventLastTime;
2826
dataSource->update();
2927
// timerEventSource->setTimeoutMS calls thread_call_enter_delayed_with_leeway, which spins.
3028
// If the previous one was too long ago, schedule another one for differential recalculation!
31-
if (timerDelta > MaxDeltaForRescheduleNs)
32-
timerEventScheduled = timerEventSource->setTimeoutMS(TimerTimeoutMs) == kIOReturnSuccess;
33-
else
34-
timerEventScheduled = false;
29+
timerEventSource->setTimeoutMS(TimerTimeoutMs);
30+
atomic_flag_clear_explicit(&timerEventScheduled, memory_order_release);
3531
}
3632

3733
IOService *SMCSuperIO::probe(IOService *provider, SInt32 *score) {
@@ -101,9 +97,9 @@ bool SMCSuperIO::start(IOService *provider) {
10197
}
10298

10399
void SMCSuperIO::quickReschedule() {
104-
if (!timerEventScheduled) {
100+
if (!atomic_flag_test_and_set_explicit(&timerEventScheduled, memory_order_acquire)) {
105101
// Make it 10 times faster
106-
timerEventScheduled = timerEventSource->setTimeoutMS(TimerTimeoutMs/10) == kIOReturnSuccess;
102+
timerEventSource->setTimeoutMS(TimerTimeoutMs/10);
107103
}
108104
}
109105

Sensors/SMCSuperIO/SMCSuperIO.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class EXPORT SMCSuperIO : public IOService {
102102
/**
103103
* Timer scheduling status
104104
*/
105-
bool timerEventScheduled {false};
105+
atomic_flag timerEventScheduled = {};
106106

107107
/**
108108
* Refresh sensor state on timer basis

0 commit comments

Comments
 (0)