Ignore:
Timestamp:
Apr 4, 2018, 2:49:02 PM (7 years ago)
Author:
alain
Message:

Fix a bug in scheduler related to RPC blocking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/scheduler.c

    r437 r438  
    125125            thread = LIST_ELEMENT( current , thread_t , sched_list );
    126126
    127             // analyse kernel thread type
    128             switch( thread->type )
     127            // execute RPC thread if non blocked
     128            if( (thread->blocked == 0)  &&
     129                (thread->type == THREAD_RPC) )
    129130            {
    130                 case THREAD_RPC:  // if non blocked and RPC FIFO non-empty
    131                 if( (thread->blocked == 0) &&
    132                     (local_fifo_is_empty( &LOCAL_CLUSTER->rpc_fifo ) == 0) )
    133                 {
    134                     spinlock_unlock( &sched->lock );
    135                     return thread;
    136                 }
    137                 break;
    138 
    139                 case THREAD_DEV:  // if non blocked and waiting queue non empty
    140                 if( (thread->blocked == 0) &&
    141                     (xlist_is_empty( XPTR( local_cxy , &thread->chdev->wait_root)) == 0) )
    142                 {
    143                     spinlock_unlock( &sched->lock );
    144                     return thread;
    145                 }
    146                 break;
    147 
    148                 default:
    149                 break;
     131                spinlock_unlock( &sched->lock );
     132                return thread;
     133            }
     134
     135            // execute DEV thread if non blocked and waiting queue non empty
     136            if( (thread->blocked == 0)  &&
     137                (thread->type == THREAD_DEV) &&
     138                (xlist_is_empty( XPTR( local_cxy , &thread->chdev->wait_root)) == 0) )
     139            {
     140                spinlock_unlock( &sched->lock );
     141                return thread;
    150142            }
    151143        } // end loop on kernel threads
     
    174166            thread = LIST_ELEMENT( current , thread_t , sched_list );
    175167
    176             // return thread if runnable
     168            // return thread if non blocked
    177169            if( thread->blocked == 0 )
    178170            {
     
    227219            process = thread->process;
    228220
    229 #if CONFIG_DEBUG_SCHED_HANDLE_SIGNALS
     221#if DEBUG_SCHED_HANDLE_SIGNALS
    230222uint32_t cycle = (uint32_t)hal_get_cycles();
    231 if( CONFIG_DEBUG_SCHED_HANDLE_SIGNALS < cycle )
     223if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    232224printk("\n[DBG] %s : thread %x in proces %x must be deleted / cycle %d\n",
    233225__FUNCTION__ , thread , process->pid , cycle );
     
    250242            thread_destroy( thread );
    251243
    252 #if CONFIG_DEBUG_SCHED_HANDLE_SIGNALS
     244#if DEBUG_SCHED_HANDLE_SIGNALS
    253245cycle = (uint32_t)hal_get_cycles();
    254 if( CONFIG_DEBUG_SCHED_HANDLE_SIGNALS < cycle )
     246if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    255247printk("\n[DBG] %s : thread %x in process %x has been deleted / cycle %d\n",
    256248__FUNCTION__ , thread , process->pid , cycle );
     
    262254                process_destroy( process );
    263255
    264 #if CONFIG_DEBUG_SCHED_HANDLE_SIGNALS
     256#if DEBUG_SCHED_HANDLE_SIGNALS
    265257cycle = (uint32_t)hal_get_cycles();
    266 if( CONFIG_DEBUG_SCHED_HANDLE_SIGNALS < cycle )
     258if( DEBUG_SCHED_HANDLE_SIGNALS < cycle )
    267259printk("\n[DBG] %s : process %x has been deleted / cycle %d\n",
    268260__FUNCTION__ , process->pid , cycle );
     
    287279    scheduler_t * sched   = &core->scheduler;
    288280 
    289 #if (CONFIG_DEBUG_SCHED_YIELD & 0x1)
    290 if( CONFIG_DEBUG_SCHED_YIELD < (uint32_t)hal_get_cycles() )
     281#if (DEBUG_SCHED_YIELD & 0x1)
     282if( DEBUG_SCHED_YIELD < (uint32_t)hal_get_cycles() )
    291283sched_display( core->lid );
    292284#endif
     
    322314    {
    323315
    324 #if CONFIG_DEBUG_SCHED_YIELD
     316#if DEBUG_SCHED_YIELD
    325317uint32_t cycle = (uint32_t)hal_get_cycles();
    326 if( CONFIG_DEBUG_SCHED_YIELD < cycle )
     318if( DEBUG_SCHED_YIELD < cycle )
    327319printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
    328320"      thread %x (%s) (%x,%x) => thread %x (%s) (%x,%x) / cycle %d\n",
     
    350342    {
    351343
    352 #if (CONFIG_DEBUG_SCHED_YIELD & 1)
     344#if (DEBUG_SCHED_YIELD & 1)
    353345uint32_t cycle = (uint32_t)hal_get_cycles();
    354 if( CONFIG_DEBUG_SCHED_YIELD < cycle )
     346if( DEBUG_SCHED_YIELD < cycle )
    355347printk("\n[DBG] %s : core[%x,%d] / cause = %s\n"
    356348"      thread %x (%s) (%x,%x) continue / cycle %d\n",
Note: See TracChangeset for help on using the changeset viewer.