@@ -305,18 +305,16 @@ static void scheduler_make_ready(Context *ctx)
305
305
}
306
306
list_remove (& ctx -> processes_list_head );
307
307
#ifndef AVM_NO_SMP
308
- bool waiting_scheduler = global -> waiting_scheduler ;
309
- if (!waiting_scheduler ) {
308
+ if (SMP_MUTEX_TRYLOCK (global -> schedulers_mutex )) {
310
309
// Start a new scheduler if none are going to take this process.
311
- if (SMP_MUTEX_TRYLOCK (global -> schedulers_mutex )) {
312
- if (global -> running_schedulers > 0
313
- && global -> running_schedulers < global -> online_schedulers
314
- && !context_get_flags (ctx , Running )) {
315
- global -> running_schedulers ++ ;
316
- smp_scheduler_start (global );
317
- }
318
- SMP_MUTEX_UNLOCK (global -> schedulers_mutex );
310
+ if (!global -> waiting_scheduler
311
+ && global -> running_schedulers > 0
312
+ && global -> running_schedulers < global -> online_schedulers
313
+ && !context_get_flags (ctx , Running )) {
314
+ global -> running_schedulers ++ ;
315
+ smp_scheduler_start (global );
319
316
}
317
+ SMP_MUTEX_UNLOCK (global -> schedulers_mutex );
320
318
}
321
319
#endif
322
320
// Move to ready queue (from waiting or running)
@@ -326,7 +324,12 @@ static void scheduler_make_ready(Context *ctx)
326
324
list_append (& global -> ready_processes , & ctx -> processes_list_head );
327
325
SMP_SPINLOCK_UNLOCK (& global -> processes_spinlock );
328
326
#ifndef AVM_NO_SMP
329
- if (waiting_scheduler ) {
327
+ if (SMP_MUTEX_TRYLOCK (global -> schedulers_mutex )) {
328
+ if (global -> waiting_scheduler ) {
329
+ sys_signal (global );
330
+ }
331
+ SMP_MUTEX_UNLOCK (global -> schedulers_mutex );
332
+ } else {
330
333
sys_signal (global );
331
334
}
332
335
#elif defined(AVM_TASK_DRIVER_ENABLED )
@@ -410,7 +413,12 @@ void scheduler_set_timeout(Context *ctx, avm_int64_t timeout)
410
413
SMP_SPINLOCK_UNLOCK (& glb -> timer_spinlock );
411
414
412
415
#ifndef AVM_NO_SMP
413
- if (glb -> waiting_scheduler ) {
416
+ if (SMP_MUTEX_TRYLOCK (glb -> schedulers_mutex )) {
417
+ if (glb -> waiting_scheduler ) {
418
+ sys_signal (glb );
419
+ }
420
+ SMP_MUTEX_UNLOCK (glb -> schedulers_mutex );
421
+ } else {
414
422
sys_signal (glb );
415
423
}
416
424
#elif defined(AVM_TASK_DRIVER_ENABLED )
0 commit comments