Changeset 436 for trunk/kernel/libk


Ignore:
Timestamp:
Mar 7, 2018, 9:02:03 AM (7 years ago)
Author:
alain
Message:

1) improve the threads and process destruction mechanism.
2) introduce FIFOs in the soclib_tty driver.

Location:
trunk/kernel/libk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/remote_barrier.c

    r408 r436  
    273273
    274274        // block & deschedule the calling thread
    275         thread_block( thread_ptr , THREAD_BLOCKED_USERSYNC );
     275        thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_USERSYNC );
    276276        sched_yield("blocked on barrier");
    277277
  • trunk/kernel/libk/remote_condvar.c

    r408 r436  
    188188
    189189    // block the calling thread
    190     thread_block( CURRENT_THREAD , THREAD_BLOCKED_USERSYNC );
     190    thread_block( XPTR( local_cxy , CURRENT_THREAD ) , THREAD_BLOCKED_USERSYNC );
    191191    sched_yield("blocked on condvar");
    192192
  • trunk/kernel/libk/remote_mutex.c

    r408 r436  
    207207
    208208        // block & deschedule the calling thread   
    209         thread_block( thread_ptr , THREAD_BLOCKED_USERSYNC );
     209        thread_block( XPTR( local_cxy , thread_ptr ) , THREAD_BLOCKED_USERSYNC );
    210210        sched_yield("blocked on mutex");
    211211
  • trunk/kernel/libk/remote_rwlock.c

    r433 r436  
    22 * remote_rwlock.c - kernel remote rwlock implementation.
    33 *
    4  * Authors    Alain   Greiner (2016,2017)
     4 * Authors    Alain   Greiner (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4141    hal_remote_sw ( XPTR( lock_cxy , &lock_ptr->count )   , 0 );
    4242
    43 #if CONFIG_DEBUG_LOCKS
    44     hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner )   , XPTR_NULL );
    45     xlist_entry_init( XPTR( lock_cxy , &lock_ptr->list ) );
     43#if CONFIG_DEBUG_REMOTE_RWLOCKS
     44hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner )   , XPTR_NULL );
     45xlist_entry_init( XPTR( lock_cxy , &lock_ptr->list ) );
    4646#endif
    4747
     
    8686    thread_ptr->remote_locks++;
    8787
    88 #if CONFIG_DEBUG_LOCKS
    89     xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
    90                      XPTR( lock_cxy ,  &lock_ptr->list ) );
     88#if CONFIG_DEBUG_REMOTE_RWLOCKS
     89xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     90                 XPTR( lock_cxy ,  &lock_ptr->list ) );
    9191#endif
    9292
     
    126126        thread_ptr->remote_locks--;
    127127
    128 #if CONFIG_DEBUG_LOCKS
    129     xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     128#if CONFIG_DEBUG_REMOTE_RWLOCKS
     129xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
    130130#endif
    131131
     
    176176    }
    177177
    178 #if CONFIG_DEBUG_LOCKS
    179     hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
    180                     XPTR( local_cxy , thread_ptr ) );
    181     xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
    182                      XPTR( lock_cxy  , &lock_ptr->list ) );
     178#if CONFIG_DEBUG_REMOTE_RWLOCKS
     179hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
     180                XPTR( local_cxy , thread_ptr ) );
     181xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     182                 XPTR( lock_cxy  , &lock_ptr->list ) );
    183183#endif   
    184184
     
    210210 
    211211#if CONFIG_LOCKS_OWNER
    212     hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
    213     xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     212hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     213xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
    214214#endif
    215215
  • trunk/kernel/libk/remote_rwlock.h

    r409 r436  
    22 * remote_rwlock.h - kernel remote_rwlock definition.
    33 *
    4  * Authors   Alain Greiner   (2016)
     4 * Authors   Alain Greiner   (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4848    uint32_t       count;           /*! current number of reader threads              */
    4949
    50 #if CONFIG_LOCKS_DEBUG
     50#if CONFIG_DEBUG_REMOTE_RWLOCKS
    5151    xptr_t         owner;           /*! extended pointer on writer thread             */
    5252    xlist_entry_t  list;            /*! member of list of remote locks taken by owner */
  • trunk/kernel/libk/remote_sem.c

    r408 r436  
    218218
    219219        // block and deschedule
    220         thread_block( this , THREAD_BLOCKED_SEM ); 
     220        thread_block( XPTR( local_cxy , this ) , THREAD_BLOCKED_SEM ); 
    221221        sched_yield("blocked on semaphore");
    222222        }
  • trunk/kernel/libk/remote_spinlock.c

    r433 r436  
    22 * remote_spinlock.c - kernel remote spinlock implementation.
    33 *
    4  * Authors  Mohamed Karaoui (2015)
    5  *          Alain   Greiner (2016)
     4 * Authors   Alain   Greiner (2016,2017,2018)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    3938        hal_remote_sw ( XPTR( cxy , &ptr->taken ) , 0 );
    4039
    41 #if CONFIG_DEBUG_LOCKS
    42         hal_remote_swd( XPTR( cxy , &ptr->owner ) , XPTR_NULL );
    43         xlist_entry_init( XPTR( cxy , &ptr->list ) );
     40#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     41hal_remote_swd( XPTR( cxy , &ptr->owner ) , XPTR_NULL );
     42xlist_entry_init( XPTR( cxy , &ptr->list ) );
    4443#endif
    4544
     
    7675                thread_ptr->remote_locks++;
    7776
    78 #if CONFIG_DEBUG_LOCKS
    79                 hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
    80                                 XPTR( local_cxy , thread_ptr) );
    81                 xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
    82                                  XPTR( lock_cxy , &lock_ptr->list ) );
     77#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     78hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) ,
     79                XPTR( local_cxy , thread_ptr) );
     80xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     81                         XPTR( lock_cxy , &lock_ptr->list ) );
    8382#endif
    8483
     
    121120        thread_ptr->remote_locks++;
    122121
    123 #if CONFIG_DEBUG_LOCKS
    124         hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
    125                         XPTR( local_cxy , thread_ptr) );
    126         xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
    127                          XPTR( lock_cxy  , &lock_ptr->list ) );
     122#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     123hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
     124                XPTR( local_cxy , thread_ptr) );
     125xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
     126                 XPTR( lock_cxy  , &lock_ptr->list ) );
    128127#endif
    129128
     
    144143        thread_t          * thread_ptr = CURRENT_THREAD;
    145144
    146 #if CONFIG_DEBUG_LOCKS
    147         hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
    148         xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     145#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     146hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     147xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
    149148#endif
    150149
     
    197196        thread_ptr->remote_locks++;
    198197
    199 #if CONFIG_DEBUG_LOCKS
    200         hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ) ,
    201                         XPTR( local_cxy , thread_ptr) );
    202         xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ) ,
    203                          XPTR( lock_cxy  , &lock_ptr->list ) );
     198#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     199hal_remote_swd( XPTR( lock_cxy  , &lock_ptr->owner ),
     200                XPTR( local_cxy , thread_ptr) );
     201xlist_add_first( XPTR( local_cxy , &thread_ptr->xlocks_root ),
     202                 XPTR( lock_cxy  , &lock_ptr->list ) );
     203
     204// if( (uint32_t)lock_ptr == 0x66788 )
     205// printk("\n@@@ %s : thread %x takes remote_spinlock %x\n",
     206//__FUNCTION__, thread_ptr, lock_ptr );
     207
    204208#endif
    205209
     
    218222        thread_t          * thread_ptr = CURRENT_THREAD;
    219223
    220 #if CONFIG_DEBUG_LOCKS
    221         hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
    222         xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     224#if CONFIG_DEBUG_REMOTE_SPINLOCKS
     225hal_remote_swd( XPTR( lock_cxy , &lock_ptr->owner ) , XPTR_NULL );
     226xlist_unlink( XPTR( lock_cxy , &lock_ptr->list ) );
     227
     228// if( (uint32_t)lock_ptr == 0x66788 )
     229// printk("\n@@@ %s : thread %x releases remote_spinlock %x\n",
     230// __FUNCTION__, thread_ptr, lock_ptr );
     231
    223232#endif
    224233
  • trunk/kernel/libk/remote_spinlock.h

    r433 r436  
    22 * remote_spinlock.h - kernel remote spinlock definition.
    33 *
    4  * Authors  Mohamed Karaoui (2016)
    5  *          Alain Greiner   (2016)
     4 * Author  Alain Greiner (2016,2017,2018)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    4241    volatile uint32_t     taken;       /*! free if 0 / taken if non zero             */
    4342
    44 #if CONFIG_LOCKS_DEBUG
     43#if CONFIG_DEBUG_REMOTE_SPINLOCKS
    4544    xptr_t                owner;       /*! extended pointer on the owner thread      */
    4645    xlist_entry_t         list;        /*! list of all remote_lock taken by owner    */
  • trunk/kernel/libk/rwlock.c

    r433 r436  
    22 * rwlock.c - kernel read/write lock synchronization.
    33 *
    4  * Author  Alain Greiner     (2016}
     4 * Author  Alain Greiner     (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    3838    lock->count   = 0;
    3939
    40 #if CONFIG_DEBUG_LOCKS
    41         lock->owner   = NULL;
    42     list_entry_init( &lock->list );
     40#if CONFIG_DEBUG_RWLOCKS
     41lock->owner   = NULL;
     42list_entry_init( &lock->list );
    4343#endif
    4444
     
    7070    this->local_locks++;
    7171
    72 #if CONFIG_DEBUG_LOCKS
    73     list_add_first( &this->locks_root , &lock->list );
     72#if CONFIG_DEBUG_RWLOCKS
     73list_add_first( &this->locks_root , &lock->list );
    7474#endif
    7575
     
    9898    this->local_locks--;
    9999
    100 #if CONFIG_DEBUG_LOCKS
    101     list_unlink( &lock->list );
     100#if CONFIG_DEBUG_RWLOCKS
     101list_unlink( &lock->list );
    102102#endif
    103103
     
    138138    this->local_locks++;
    139139
    140 #if CONFIG_DEBUG_LOCKS
    141     lock->owner = this;
    142     list_add_first( &this->locks_root , &lock->list );
     140#if CONFIG_DEBUG_RWLOCKS
     141lock->owner = this;
     142list_add_first( &this->locks_root , &lock->list );
    143143#endif
    144144
     
    157157        hal_disable_irq( &mode );
    158158 
    159 #if CONFIG_DEBUG_LOCKS
    160     lock->owner = NULL;
    161     list_unlink( &lock->list );
     159#if CONFIG_DEBUG_RWLOCKS
     160lock->owner = NULL;
     161list_unlink( &lock->list );
    162162#endif
    163163
  • trunk/kernel/libk/rwlock.h

    r423 r436  
    22 * rwlock.h - kernel read/write lock definition.
    33 *
    4  * Author   Alain Greiner    (2016)
     4 * Author   Alain Greiner    (2016,2017,2018)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5959    uint32_t            count;            /*! number of simultaneous readers threads      */
    6060
    61 #if CONFIG_LOCKS_DEBUG
     61#if CONFIG_DEBUG_RWLOCKS
    6262        struct thread_s   * owner;            /*! pointer on curent writer thread             */
    6363    list_entry_t        list;             /*! member of list of locks taken by owner      */
  • trunk/kernel/libk/spinlock.c

    r433 r436  
    3838    lock->taken = 0;
    3939
    40 #if CONFIG_DEBUG_LOCKS
    41     lock->owner = NULL;
    42     list_entry_init( &lock->list );
     40#if CONFIG_DEBUG_SPINLOCKS
     41lock->owner = NULL;
     42list_entry_init( &lock->list );
    4343#endif
    4444
     
    7171    this->local_locks++;
    7272
    73 #if CONFIG_DEBUG_LOCKS
    74     lock->owner = this;
    75     list_add_first( &this->locks_root , &lock->list );
     73#if CONFIG_DEBUG_SPINLOCKS
     74lock->owner = this;
     75list_add_first( &this->locks_root , &lock->list );
    7676#endif
    7777
     
    8686    thread_t * this = CURRENT_THREAD;;
    8787
    88 #if CONFIG_DEBUG_LOCKS
    89     lock->owner = NULL;
    90     list_unlink( &lock->list );
     88#if CONFIG_DEBUG_SPINLOCKS
     89lock->owner = NULL;
     90list_unlink( &lock->list );
    9191#endif
    9292
     
    132132    this->local_locks++;
    133133
    134 #if CONFIG_DEBUG_LOCKS
    135     lock->owner = this;
    136     list_add_first( &this->locks_root , &lock->list );
     134#if CONFIG_DEBUG_SPINLOCKS
     135lock->owner = this;
     136list_add_first( &this->locks_root , &lock->list );
    137137#endif
    138138
     
    162162        this->local_locks++;
    163163
    164 #if CONFIG_DEBUG_LOCKS
    165         lock->owner = this;
    166         list_add_first( &this->locks_root , &lock->list );
     164#if CONFIG_DEBUG_SPINLOCKS
     165lock->owner = this;
     166list_add_first( &this->locks_root , &lock->list );
    167167#endif
    168168
     
    177177    thread_t * this = CURRENT_THREAD;
    178178
    179 #if CONFIG_DEBUG_LOCKS
    180     lock->owner = NULL;
    181     list_unlink( &lock->list );
     179#if CONFIG_DEBUG_SPINLOCKS
     180lock->owner = NULL;
     181list_unlink( &lock->list );
    182182#endif
    183183
  • trunk/kernel/libk/spinlock.h

    r409 r436  
    22 * spinlock.h: kernel spinlock definition     
    33 *
    4  * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    5  *          Alain Greiner    (2016)
     4 * Authors  Alain Greiner (2016,2017,2018)
    65 *
    76 * Copyright (c) UPMC Sorbonne Universites
     
    6362        uint32_t            taken;             /*! state : free if zero / taken if non zero  */
    6463
    65 #if CONFIG_LOCKS_DEBUG
     64#if CONFIG_DEBUG_SPINLOCKS
    6665        struct thread_s   * owner;             /*! pointer on curent owner thread            */
    6766    list_entry_t        list;              /*! member of list of locks taken by owner    */
Note: See TracChangeset for help on using the changeset viewer.