@@ -124,8 +124,6 @@ This will use software-interrupt 3 which isn't available for anything else to wa
124124 // we do not care about race conditions between the load and store operations,
125125 // interrupts will only set this value to true.
126126 if SIGNAL_WORK_THREAD_MODE [ cpu] . load ( Ordering :: SeqCst ) {
127- SIGNAL_WORK_THREAD_MODE [ cpu] . store ( false , Ordering :: SeqCst ) ;
128-
129127 // if there is work to do, exit critical section and loop back to polling
130128 unsafe {
131129 core:: arch:: asm!(
@@ -141,6 +139,8 @@ This will use software-interrupt 3 which isn't available for anything else to wa
141139 // `waiti` if it needs to be inside the CS.
142140 unsafe { core:: arch:: asm!( "waiti 0" ) } ;
143141 }
142+ // If this races and some waker sets the signal, we'll reset it, but still poll.
143+ SIGNAL_WORK_THREAD_MODE [ cpu] . store ( false , Ordering :: SeqCst ) ;
144144 }
145145
146146 #[ cfg( all( riscv, low_power_wait) ) ]
@@ -149,17 +149,14 @@ This will use software-interrupt 3 which isn't available for anything else to wa
149149 // interrupts will only set this value to true.
150150 critical_section:: with ( |_| {
151151 // if there is work to do, loop back to polling
152- // TODO can we relax this?
153- if SIGNAL_WORK_THREAD_MODE [ cpu] . load ( Ordering :: SeqCst ) {
154- SIGNAL_WORK_THREAD_MODE [ cpu] . store ( false , Ordering :: SeqCst ) ;
155- }
156- // if not, wait for interrupt
157- else {
152+ if !SIGNAL_WORK_THREAD_MODE [ cpu] . load ( Ordering :: SeqCst ) {
153+ // if not, wait for interrupt
158154 unsafe { core:: arch:: asm!( "wfi" ) } ;
159155 }
160156 } ) ;
161- // if an interrupt occurred while waiting, it will be serviced
162- // here
157+ // if an interrupt occurred while waiting, it will be serviced here
158+ // If this races and some waker sets the signal, we'll reset it, but still poll.
159+ SIGNAL_WORK_THREAD_MODE [ cpu] . store ( false , Ordering :: SeqCst ) ;
163160 }
164161}
165162
0 commit comments