@@ -174,17 +174,25 @@ impl Spinor {
174
174
// acquire a write lock on the unit
175
175
#[ cfg( not( test) ) ]
176
176
{
177
- let response = send_message ( self . conn ,
178
- Message :: new_blocking_scalar ( Opcode :: AcquireExclusive . to_usize ( ) . unwrap ( ) ,
179
- self . token [ 0 ] as usize ,
180
- self . token [ 1 ] as usize ,
181
- self . token [ 2 ] as usize ,
182
- self . token [ 3 ] as usize ,
183
- )
184
- ) . expect ( "couldn't send AcquireExclusive message to Spinor hardware!" ) ;
185
- if let xous:: Result :: Scalar1 ( result) = response {
186
- if result == 0 {
187
- return Err ( SpinorError :: BusyTryAgain )
177
+ const RETRY_LIMIT : usize = 5 ;
178
+ for i in 0 ..RETRY_LIMIT {
179
+ let response = send_message ( self . conn ,
180
+ Message :: new_blocking_scalar ( Opcode :: AcquireExclusive . to_usize ( ) . unwrap ( ) ,
181
+ self . token [ 0 ] as usize ,
182
+ self . token [ 1 ] as usize ,
183
+ self . token [ 2 ] as usize ,
184
+ self . token [ 3 ] as usize ,
185
+ )
186
+ ) . expect ( "couldn't send AcquireExclusive message to Spinor hardware!" ) ;
187
+ if let xous:: Result :: Scalar1 ( result) = response {
188
+ if result == 0 {
189
+ if i == RETRY_LIMIT - 1 {
190
+ return Err ( SpinorError :: BusyTryAgain )
191
+ }
192
+ xous:: yield_slice ( ) ;
193
+ } else {
194
+ break ;
195
+ }
188
196
}
189
197
}
190
198
}
@@ -235,17 +243,25 @@ impl Spinor {
235
243
// acquire a write lock on the unit
236
244
#[ cfg( not( test) ) ]
237
245
{
238
- let response = send_message ( self . conn ,
239
- Message :: new_blocking_scalar ( Opcode :: AcquireExclusive . to_usize ( ) . unwrap ( ) ,
240
- self . token [ 0 ] as usize ,
241
- self . token [ 1 ] as usize ,
242
- self . token [ 2 ] as usize ,
243
- self . token [ 3 ] as usize ,
244
- )
245
- ) . expect ( "couldn't send AcquireExclusive message to Spinor hardware!" ) ;
246
- if let xous:: Result :: Scalar1 ( result) = response {
247
- if result == 0 {
248
- return Err ( SpinorError :: BusyTryAgain )
246
+ const RETRY_LIMIT : usize = 5 ;
247
+ for i in 0 ..RETRY_LIMIT {
248
+ let response = send_message ( self . conn ,
249
+ Message :: new_blocking_scalar ( Opcode :: AcquireExclusive . to_usize ( ) . unwrap ( ) ,
250
+ self . token [ 0 ] as usize ,
251
+ self . token [ 1 ] as usize ,
252
+ self . token [ 2 ] as usize ,
253
+ self . token [ 3 ] as usize ,
254
+ )
255
+ ) . expect ( "couldn't send AcquireExclusive message to Spinor hardware!" ) ;
256
+ if let xous:: Result :: Scalar1 ( result) = response {
257
+ if result == 0 {
258
+ if i == RETRY_LIMIT - 1 {
259
+ return Err ( SpinorError :: BusyTryAgain )
260
+ }
261
+ xous:: yield_slice ( ) ;
262
+ } else {
263
+ break ;
264
+ }
249
265
}
250
266
}
251
267
}
0 commit comments