Changeset 472


Ignore:
Timestamp:
Aug 21, 2018, 5:58:40 PM (3 years ago)
Author:
alain
Message:

Fix the bug found by Axel in the process_register_thread() function

This function must use a busy-waiting lock when the thread is the IDLE_THREAD,
because we cennot use a descheduling policy when the IDLE_THREAD desriptor
is not initialised.

File:
1 edited

Legend:

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

    r469 r472  
    10401040                                 trdid_t   * trdid )
    10411041{
    1042     ltid_t   ltid;
    1043     bool_t   found = false;
     1042    ltid_t         ltid;
     1043    thread_type_t  type;
     1044    reg_t          save_sr;
     1045    bool_t         found = false;
     1046 
    10441047
    10451048    assert( (process != NULL) , __FUNCTION__ , "process argument is NULL" );
     
    10471050    assert( (thread != NULL) , __FUNCTION__ , "thread argument is NULL" );
    10481051
    1049     // take lock protecting th_tbl
    1050     spinlock_lock( &process->th_lock );
     1052    // take lock protecting th_tbl, depending on thread type:
     1053    // we don't want to use a descheduling policy for idle thread initialisation
     1054    if( type == THREAD_IDLE )  spinlock_lock_busy( &process->th_lock , &save_sr );
     1055    else                       spinlock_lock( &process->th_lock );
    10511056
    10521057    // search a free slot in th_tbl[]
     
    10721077    // release lock protecting th_tbl
    10731078    hal_fence();
    1074     spinlock_unlock( &process->th_lock );
     1079    if( type == THREAD_IDLE )  spinlock_unlock_busy( &process->th_lock , save_sr );
     1080    else                       spinlock_unlock( &process->th_lock );
    10751081
    10761082    return (found) ? 0 : ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.