Changeset 666


Ignore:
Timestamp:
Oct 10, 2020, 5:27:12 PM (13 months ago)
Author:
alain
Message:

Cosmetic.

Location:
trunk/kernel/libk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/bits.h

    r657 r666  
    229229 * This function takes a positive integer <val> as input argument, and returns the smallest
    230230 * integer <order> such as : 1<<order >= val.
    231  * In other words, <order> is the min number of bits to encode <val> values.
     231 * In other words, <order> is the min number of bits to encode the <val> values.
    232232 *********************************************************************************************
    233233 * @ val   : value to analyse
  • trunk/kernel/libk/busylock.c

    r624 r666  
    11/*
    2  * busylock.c - local kernel-busy waiting lock implementation.
     2 * busylock.c - local kernel busy waiting lock implementation.
    33 *
    4  * Authors     Alain Greiner (2016,2017,2018,2019)
     4 * Authors     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4545    lock->type    = type;
    4646
    47 #if DEBUG_BUSYLOCK
     47#if DEBUG_BUSYLOCK_TYPE
    4848    xlist_entry_init( XPTR( local_cxy , &lock->xlist ) );
    4949#endif
  • trunk/kernel/libk/busylock.h

    r624 r666  
    22 * busylock.h: local kernel busy-waiting lock definition.     
    33 *
    4  * Authors  Alain Greiner (2016,2017,2018,2019)
     4 * Authors  Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    7272    reg_t               save_sr;     /*! SR value                                         */
    7373
    74 #if DEBUG_BUSYLOCK
     74#if DEBUG_BUSYLOCK_TYPE
    7575    xlist_entry_t       xlist;       /*! member of list of locks taken by same thread     */
    7676#endif
  • trunk/kernel/libk/queuelock.c

    r629 r666  
    4747#if DEBUG_QUEUELOCK_TYPE
    4848thread_t * this = CURRENT_THREAD;
    49 if( (type      == DEBUG_QUEUELOCK_TYPE) &&
    50     (lock      == DEBUG_QUEUELOCK_PTR ) &&
    51     (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    52 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
     49bool_t     cond = (type == DEBUG_QUEUELOCK_TYPE) &&
     50                  (((local_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     51                    (lock == (queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     52                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     53                    (DEBUG_QUEUELOCK_PTR == 0)));
     54if( cond ) printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    5355__FUNCTION__, this->process->pid, this->trdid,
    5456lock_type_str[type], local_cxy, lock );
     
    7072#if DEBUG_QUEUELOCK_TYPE
    7173uint32_t   lock_type = lock->lock.type;
     74bool_t     cond = (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     75                  (((local_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     76                    (lock == (queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     77                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     78                    (DEBUG_QUEUELOCK_PTR == 0)));
    7279#endif
    7380
     
    7784
    7885#if DEBUG_QUEUELOCK_TYPE
    79 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    80     (lock      == DEBUG_QUEUELOCK_PTR ) &&
    81     (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    82 printk("\n[%s ] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
     86if( cond ) printk("\n[%s ] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
    8387__FUNCTION__, this->process->pid, this->trdid,
    8488lock_type_str[lock_type], local_cxy, lock );
     
    104108
    105109#if DEBUG_QUEUELOCK_TYPE
    106 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    107     (lock      == DEBUG_QUEUELOCK_PTR ) &&
    108     (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    109 printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
     110if( cond ) printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
    110111__FUNCTION__, this->process->pid, this->trdid,
    111112lock_type_str[lock_type], local_cxy, lock );
     
    132133uint32_t   lock_type = lock->lock.type;
    133134thread_t * this      = CURRENT_THREAD;
    134 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    135     (lock      == DEBUG_QUEUELOCK_PTR ) &&
    136     (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    137 printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n",
     135bool_t     cond = (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     136                  (((local_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     137                    (lock == (queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     138                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     139                    (DEBUG_QUEUELOCK_PTR == 0)));
     140#endif
     141
     142#if DEBUG_QUEUELOCK_TYPE
     143if( cond ) printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n",
    138144__FUNCTION__, this->process->pid, this->trdid,
    139145lock_type_str[lock_type], local_cxy, lock );
     
    150156
    151157#if DEBUG_QUEUELOCK_TYPE
    152 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    153     (lock      == DEBUG_QUEUELOCK_PTR ) &&
    154     (local_cxy == DEBUG_QUEUELOCK_CXY ) )
    155 printk("\n[%s] thread[%x,%x] UNBLOCK thread [%x,%x] / q_lock %s [%x,%x]\n",
     158if( cond ) printk("\n[%s] thread[%x,%x] UNBLOCK thread [%x,%x] / q_lock %s [%x,%x]\n",
    156159__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
    157160lock_type_str[lock_type], local_cxy, lock );
  • trunk/kernel/libk/queuelock.h

    r563 r666  
    4141 * and a thread T' executing the release() function, the "queuelock" is protected
    4242 * by a "busylock" used by these two access functions.
    43  * WARNING: this queuelock is NOT registered in the thread "local_locks" field.
    4443 ******************************************************************************************/
    4544 
  • trunk/kernel/libk/remote_buf.c

    r657 r666  
    3131#include <remote_buf.h>
    3232
    33 ///////////////////////////////////////////
    34 error_t remote_buf_create( xptr_t   buf_xp,
    35                            uint32_t size )
     33/////////////////////////////////////////
     34error_t remote_buf_init( xptr_t   buf_xp,
     35                         uint32_t size )
    3636{
    3737    kmem_req_t     req;
     
    4242
    4343    // allocate the data buffer
    44     if( size >= CONFIG_PPM_PAGE_SIZE )
     44    if( size == 0 )
     45    {
     46        data = NULL;
     47    }
     48    else if( size >= CONFIG_PPM_PAGE_SIZE )
    4549    {
    4650        req.type  = KMEM_PPM;
     
    4852        req.flags = AF_NONE;
    4953        data = kmem_remote_alloc( buf_cxy , &req );
     54
     55        if( data == NULL )  return -1;
    5056    }
    5157    else
     
    5561        req.flags = AF_NONE;
    5662        data = kmem_remote_alloc( buf_cxy , &req );
    57     }
    58 
    59     if( data == NULL )  return -1;
     63
     64        if( data == NULL )  return -1;
     65    }
    6066
    6167    // initialize buffer descriptor
     
    6874    return 0;
    6975
    70 }  // end remote_buf_create()
     76}  // end remote_buf_init()
    7177
    7278/////////////////////////////////////////
     
    7884    cxy_t          buf_cxy = GET_CXY( buf_xp );
    7985
    80     // release memory allocated to data buffer
    81     if( buf_ptr->size >= CONFIG_PPM_PAGE_SIZE )
     86    uint32_t size = hal_remote_l32( XPTR( buf_cxy , &buf_ptr->size ));
     87
     88    // release memory allocated to data buffer if required
     89    if( size == 0 )
     90    {
     91        return;
     92    }
     93    else if( size >= CONFIG_PPM_PAGE_SIZE )
    8294    {
    8395        req.type  = KMEM_PPM;
  • trunk/kernel/libk/remote_buf.h

    r657 r666  
    3232 * This structure and the associated access functions define a remotely accessible,
    3333 * kernel buffer, handled as a single-reader & single-writer FIFO.
    34  * Each buffer slot contains one byte, and the number of slots is dynamically
    35  * defined by an argument of the "remote_buf_create()" function.
    36  * The "put()" and "get()" access functions defined below move another buffer,
    37  * (can be in kernel or in user space) to/from this circular kernel buffer.
     34 * This kernel buffer is implementes as an array of bytes, whose size is
     35 * dynamically defined by an argument of the "remote_buf_init()" function.
     36 * The "put()" and "get()" functions defined below move the content of another
     37 * buffer (can be in kernel or in user space) to/from this circular kernel buffer.
    3838 * This structure is NOT protected by a lock, as the only shared variable is the
    39  * "sts" variable, that is updated by hal_remote_atomic_add() access primitives.
    40  * It is used by to implement the socket receive buffer.
     39 * "sts" variable, that is updated by the hal_remote_atomic_add() primitive.
     40 * It is used to implement the three socket buffers (rx_buf / r2tq / crqq).
    4141 * - the "ptw" field defines the first empty slot (for write).
    4242 * - the "ptr" field defines the first non empty slot (for read).
     
    5858 * argument. It allocates memory for the data, as defined by the <size> argument,
    5959 * and initializes the buffer as empty. It must be called by a local thread.
     60 * No memory is allocated if <size> value is 0.
    6061 ************************************************************************************
    6162 * @ buf_xp    : [in] extended pointer on buffer descriptor.
    62  * @ size      : [in] number of bytes in buffer.
    63  * @ return  0 if success / return -1 if failure (no memory).
     63 * @ size      : [in] number of bytes in buffer / no memory allocated when null.
     64 * @ return  0 if success / return -1 if memory failure.
    6465 ***********************************************************************************/
    65 error_t remote_buf_create( xptr_t   buf_xp,
    66                            uint32_t size );
     66error_t remote_buf_init( xptr_t   buf_xp,
     67                         uint32_t size );
    6768
    6869/************************************************************************************
  • trunk/kernel/libk/remote_busylock.c

    r624 r666  
    22 * remote_busylock.c - remote kernel busy-waiting lock implementation.
    33 *
    4  * Authors     Alain Greiner (2016,2017,2018,2019)
     4 * Authors     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    5050    hal_remote_s32( XPTR( lock_cxy , &lock_ptr->type    ) , type );
    5151
    52 #if DEBUG_BUSYLOCK
     52#if DEBUG_BUSYLOCK_TYPE
    5353    xlist_entry_init( XPTR( lock_cxy , &lock_ptr->xlist ) );
    5454#endif
     
    8585    hal_fence();
    8686   
    87 #if DEBUG_BUSYLOCK
     87#if DEBUG_BUSYLOCK_TYPE
    8888uint32_t type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) );
    8989if( type != LOCK_CHDEV_TXT0 )
     
    9393    xlist_add_last( root_xp , XPTR( lock_cxy  , &lock_ptr->xlist ) );
    9494}
    95 #endif
    96 
    97 #if( DEBUG_BUSYLOCK & 1 )
    98 if( (type != LOCK_CHDEV_TXT0) &&
     95if( (type               == DEBUG_BUSYLOCK_TYPE) &&
    9996    (this->process->pid == DEBUG_BUSYLOCK_PID) &&
    100     (this->trdid == DEBUG_BUSYLOCK_TRDID) )
     97    (this->trdid        == DEBUG_BUSYLOCK_TRDID) )
    10198{
    10299    printk("\n[%s] thread[%x,%x] ACQUIRE lock %s\n",
     
    128125    hal_fence();
    129126
    130 #if DEBUG_BUSYLOCK
     127#if DEBUG_BUSYLOCK_TYPE
    131128uint32_t type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) );
    132129if( type != LOCK_CHDEV_TXT0 )
     
    135132    xlist_unlink( XPTR( lock_cxy  , &lock_ptr->xlist ) );
    136133}
    137 #endif
    138 
    139 #if( DEBUG_BUSYLOCK & 1 )
    140 if( (type != LOCK_CHDEV_TXT0) &&
     134if( (type               == DEBUG_BUSYLOCK_TYPE) &&
    141135    (this->process->pid == DEBUG_BUSYLOCK_PID) &&
    142     (this->trdid == DEBUG_BUSYLOCK_TRDID) )
     136    (this->trdid        == DEBUG_BUSYLOCK_TRDID) )
    143137{
    144138    printk("\n[%s] thread[%x,%x] RELEASE lock %s\n",
  • trunk/kernel/libk/remote_busylock.h

    r624 r666  
    22 * remote_busylock.h: remote kernel busy-waiting lock definition.     
    33 *
    4  * Authors  Alain Greiner (2016,2017,2018,2019)
     4 * Authors  Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    7474    reg_t               save_sr;     /*! SR value                                         */
    7575
    76 #if DEBUG_BUSYLOCK
     76#if DEBUG_BUSYLOCK_TYPE
    7777    xlist_entry_t       xlist;       /*! member of list of locks taken by same thread     */
    7878#endif
  • trunk/kernel/libk/remote_queuelock.c

    r629 r666  
    5656#if DEBUG_QUEUELOCK_TYPE
    5757thread_t * this = CURRENT_THREAD;
    58 if( (type     == DEBUG_QUEUELOCK_TYPE) &&
    59     (lock_ptr == DEBUG_QUEUELOCK_PTR ) &&
    60     (lock_cxy == DEBUG_QUEUELOCK_CXY ) )
    61 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
     58bool_t     cond = (type == DEBUG_QUEUELOCK_TYPE) &&
     59                  (((lock_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     60                    (lock_ptr == (remote_queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     61                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     62                    (DEBUG_QUEUELOCK_PTR == 0)));
     63if( cond )printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    6264__FUNCTION__, this->process->pid, this->trdid,
    6365lock_type_str[type], lock_cxy, lock_ptr );
     
    7072{
    7173    thread_t * this = CURRENT_THREAD;
    72 
    73     // check calling thread can yield
    74     thread_assert_can_yield( this , __FUNCTION__ );
    7574
    7675    // get lock cluster and local pointer
     
    7877    remote_queuelock_t * lock_ptr = GET_PTR( lock_xp );
    7978
    80 #if DEBUG_QUEUELOCK_TYPE
    81 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     79    // check calling thread can yield
     80    thread_assert_can_yield( this , __FUNCTION__ );
     81
     82#if DEBUG_QUEUELOCK_TYPE
     83uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     84bool_t     cond = (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     85                  (((lock_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     86                    (lock_ptr == (remote_queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     87                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     88                    (DEBUG_QUEUELOCK_PTR == 0)));
    8289#endif
    8390
     
    93100
    94101#if DEBUG_QUEUELOCK_TYPE
    95 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    96     (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
    97     (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    98 printk("\n[%s] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
     102if( cond ) printk("\n[%s] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n",
    99103__FUNCTION__, this->process->pid, this->trdid,
    100104lock_type_str[lock_type], lock_cxy, lock_ptr );
     
    121125
    122126#if DEBUG_QUEUELOCK_TYPE
    123 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    124     (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
    125     (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    126 printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
     127if( cond ) printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n",
    127128__FUNCTION__, this->process->pid, this->trdid,
    128129lock_type_str[lock_type], lock_cxy, lock_ptr );
     
    149150    remote_queuelock_t * lock_ptr = GET_PTR( lock_xp );
    150151
     152#if DEBUG_QUEUELOCK_TYPE
     153thread_t * this      = CURRENT_THREAD;
     154uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     155bool_t     cond = (lock_type == DEBUG_QUEUELOCK_TYPE) &&
     156                  (((lock_cxy == (cxy_t)DEBUG_QUEUELOCK_CXY) &&
     157                    (lock_ptr == (remote_queuelock_t*)DEBUG_QUEUELOCK_PTR)) ||
     158                   ((DEBUG_QUEUELOCK_CXY == 0) &&
     159                    (DEBUG_QUEUELOCK_PTR == 0)));
     160#endif
     161
    151162    // build extended pointer on busylock protecting queuelock
    152163    xptr_t busylock_xp = XPTR( lock_cxy , &lock_ptr->lock );
     
    156167
    157168#if DEBUG_QUEUELOCK_TYPE
    158 thread_t * this      = CURRENT_THREAD;
    159 uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
    160 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    161     (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
    162     (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
    163 printk("\n[%s] thread[%x,%x] RELEASE q_lock %s (%x,%x)\n",
     169if( cond ) printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n",
    164170__FUNCTION__, this->process->pid, this->trdid,
    165171lock_type_str[lock_type], lock_cxy, lock_ptr );
     
    179185
    180186#if DEBUG_QUEUELOCK_TYPE
    181 if( (lock_type == DEBUG_QUEUELOCK_TYPE) &&
    182     (lock_ptr  == DEBUG_QUEUELOCK_PTR ) &&
    183     (lock_cxy  == DEBUG_QUEUELOCK_CXY ) )
     187if( cond )
    184188{
    185189    trdid_t     trdid   = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
  • trunk/kernel/libk/remote_queuelock.h

    r563 r666  
    4141 * and a thread T' executing the release() function, the "remote_queuelock" is protected
    4242 * by a "remote_busylock" used by these two access functions.
    43  * WARNING: this remote_queuelock is NOT registered in the thread "remote_locks" field.
    4443 ******************************************************************************************/
    4544 
     
    5958/*******************************************************************************************
    6059 * This function initializes a local remote_queuelock in free state.
    61  * The <name> argument defines the lock usage and is only used for debug.
     60 * The <type> argument defines the lock usage and is only used for debug.
    6261 * This type is actually stored in the associated busylock descriptor.
    6362 *******************************************************************************************
  • trunk/kernel/libk/remote_rwlock.c

    r629 r666  
    5555#if DEBUG_RWLOCK_TYPE
    5656thread_t * this = CURRENT_THREAD;
    57 if( (type               == DEBUG_RWLOCK_TYPE) &&
    58     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    59     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     57bool_t     cond = (type == DEBUG_RWLOCK_TYPE) &&
     58                  (((lock_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     59                    (lock_ptr == (remote_queuelock_t*)DEBUG_RWLOCK_PTR)) ||
     60                   ((DEBUG_RWLOCK_CXY == 0) &&
     61                    (DEBUG_RWLOCK_PTR == 0)));
     62if( cond )
    6063printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    6164__FUNCTION__, this->process->pid, this->trdid,
     
    7881
    7982#if DEBUG_RWLOCK_TYPE
    80 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     83uint32_t lock_type   = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     84bool_t   cond        = (type == DEBUG_RWLOCK_TYPE) &&
     85                       (((lock_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     86                         (lock_ptr == (remote_queuelock_t*)DEBUG_RWLOCK_PTR)) ||
     87                        ((DEBUG_RWLOCK_CXY == 0) &&
     88                         (DEBUG_RWLOCK_PTR == 0)));
     89xptr_t   wr_root_xp  = XPTR( lock_cxy , &lock_ptr->wr_xroot );
    8190#endif
    8291
     
    95104
    96105#if DEBUG_RWLOCK_TYPE
    97 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    98     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    99     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    100 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
     106if( cond )
     107printk("\n[%s] thread[%x,%x] READ BLOCK on %s [%x,%x]\n"
     108"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    101109__FUNCTION__, this->process->pid, this->trdid,
    102110lock_type_str[lock_type], lock_cxy, lock_ptr,
    103 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     111hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     112xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    104113#endif
    105114        // get pointer on calling thread
     
    128137
    129138#if DEBUG_RWLOCK_TYPE
    130 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    131     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    132     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    133 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
     139if( cond )
     140printk("\n[%s] thread[%x,%x] READ ACQUIRE %s [%x,%x]\n"
     141"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    134142__FUNCTION__, this->process->pid, this->trdid,
    135143lock_type_str[lock_type], lock_cxy, lock_ptr,
    136 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     144hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     145xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    137146#endif
    138147
     
    155164
    156165#if DEBUG_RWLOCK_TYPE
    157 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     166uint32_t lock_type   = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     167bool_t   cond        = (type == DEBUG_RWLOCK_TYPE) &&
     168                       (((lock_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     169                         (lock_ptr == (remote_queuelock_t*)DEBUG_RWLOCK_PTR)) ||
     170                        ((DEBUG_RWLOCK_CXY == 0) &&
     171                         (DEBUG_RWLOCK_PTR == 0)));
     172xptr_t   rd_root_xp  = XPTR( lock_cxy , &lock_ptr->rd_xroot );
    158173#endif
    159174
     
    172187
    173188#if DEBUG_RWLOCK_TYPE
    174 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    175     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    176     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    177 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
     189if( cond )
     190printk("\n[%s] thread[%x,%x] WRITE BLOCK on %s [%x,%x]\n"
     191"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    178192__FUNCTION__, this->process->pid, this->trdid,
    179193lock_type_str[lock_type], lock_cxy, lock_ptr,
    180 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     194hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     195xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    181196#endif
    182197
     
    204219
    205220#if DEBUG_RWLOCK_TYPE
    206 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    207     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    208     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    209 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
     221if( cond )
     222printk("\n[%s] thread[%x,%x] WRITE ACQUIRE %s [%x,%x]\n"
     223"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    210224__FUNCTION__, this->process->pid, this->trdid,
    211225lock_type_str[lock_type], lock_cxy, lock_ptr,
    212 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     226hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     227xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    213228#endif
    214229
     
    244259thread_t * this      = CURRENT_THREAD;
    245260uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     261bool_t     cond      = (type == DEBUG_RWLOCK_TYPE) &&
     262                       (((lock_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     263                         (lock_ptr == (remote_queuelock_t*)DEBUG_RWLOCK_PTR)) ||
     264                        ((DEBUG_RWLOCK_CXY == 0) &&
     265                         (DEBUG_RWLOCK_PTR == 0)));
    246266xptr_t     taken_xp  = XPTR( lock_cxy , &lock_ptr->taken );
    247 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    248     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    249     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    250 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
     267#endif
     268
     269#if DEBUG_RWLOCK_TYPE
     270if( cond )
     271printk("\n[%s] thread[%x,%x] READ RELEASE %s [%x,%x]\n"
     272"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    251273__FUNCTION__, this->process->pid, this->trdid,
    252274lock_type_str[lock_type], lock_cxy, lock_ptr,
    253 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     275hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     276xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    254277#endif
    255278
     
    270293
    271294#if DEBUG_RWLOCK_TYPE
    272 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    273     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    274     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     295if( cond )
    275296{
    276297    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    303324
    304325#if DEBUG_RWLOCK_TYPE
    305 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    306     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    307     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     326if( cond )
    308327{
    309328    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    349368thread_t * this      = CURRENT_THREAD;
    350369uint32_t   lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) );
     370bool_t     cond      = (type == DEBUG_RWLOCK_TYPE) &&
     371                       (((lock_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     372                         (lock_ptr == (remote_queuelock_t*)DEBUG_RWLOCK_PTR)) ||
     373                        ((DEBUG_RWLOCK_CXY == 0) &&
     374                         (DEBUG_RWLOCK_PTR == 0)));
    351375xptr_t     count_xp  = XPTR( lock_cxy , &lock_ptr->count );
    352 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    353     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    354     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
    355 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
     376#endif
     377
     378#if DEBUG_RWLOCK_TYPE
     379if( cond )
     380printk("\n[%s] thread[%x,%x] WRITE RELEASE %s [%x,%x]\n"
     381"     taken %d / count %d / wr_empty %d / rd_empty %d\n",
    356382__FUNCTION__, this->process->pid, this->trdid,
    357383lock_type_str[lock_type], lock_cxy, lock_ptr,
    358 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) );
     384hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ),
     385xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) );
    359386#endif
    360387
     
    374401
    375402#if DEBUG_RWLOCK_TYPE
    376 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    377     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    378     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     403if( cond )
    379404{
    380405    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
     
    406431
    407432#if DEBUG_RWLOCK_TYPE
    408 if( (lock_type          == DEBUG_RWLOCK_TYPE) &&
    409     ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) &&
    410     (lock_cxy           == DEBUG_RWLOCK_CXY ) )
     433if( cond )
    411434{
    412435    trdid_t     trdid     = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) );
  • trunk/kernel/libk/rwlock.c

    r629 r666  
    5252#if DEBUG_RWLOCK_TYPE
    5353thread_t * this = CURRENT_THREAD;
    54 if( (type           == DEBUG_RWLOCK_TYPE) &&
    55     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    56     (local_cxy      == DEBUG_RWLOCK_CXY ) )
    57 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
     54bool_t     cond = (lock_type == DEBUG_RWLOCK_TYPE) &&
     55                  (((local_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     56                    (lock == (rwlock_t*)DEBUG_RWLOCK_PTR)) ||
     57                   ((DEBUG_RWLOCK_CXY == 0) &&
     58                    (DEBUG_RWLOCK_PTR == 0)));
     59if( cond ) printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n",
    5860__FUNCTION__, this->process->pid, this->trdid,
    5961lock_type_str[type], local_cxy, lock );
     
    7476
    7577#if DEBUG_RWLOCK_TYPE
    76 uint32_t lock_type = lock->lock.type;
     78uint32_t   lock_type = lock->lock.type;
     79bool_t     cond = (lock_type == DEBUG_RWLOCK_TYPE) &&
     80                  (((local_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     81                    (lock == (rwlock_t*)DEBUG_RWLOCK_PTR)) ||
     82                   ((DEBUG_RWLOCK_CXY == 0) &&
     83                    (DEBUG_RWLOCK_PTR == 0)));
    7784#endif
    7885
     
    8289
    8390#if DEBUG_RWLOCK_TYPE
    84 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    85     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    86     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     91if( cond )
    8792printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    8893__FUNCTION__, this->process->pid, this->trdid,
     
    109114
    110115#if DEBUG_RWLOCK_TYPE
    111 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    112     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    113     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     116if( cond )
    114117printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    115118__FUNCTION__, this->process->pid, this->trdid,
     
    134137
    135138#if DEBUG_RWLOCK_TYPE
    136 uint32_t lock_type = lock->lock.type;
     139uint32_t   lock_type = lock->lock.type;
     140bool_t     cond = (lock_type == DEBUG_RWLOCK_TYPE) &&
     141                  (((local_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     142                    (lock == (rwlock_t*)DEBUG_RWLOCK_PTR)) ||
     143                   ((DEBUG_RWLOCK_CXY == 0) &&
     144                    (DEBUG_RWLOCK_PTR == 0)));
    137145#endif
    138146
     
    142150
    143151#if DEBUG_RWLOCK_TYPE
    144 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    145     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    146     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     152if( cond )
    147153printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n",
    148154__FUNCTION__, this->process->pid, this->trdid,
     
    169175
    170176#if DEBUG_RWLOCK_TYPE
    171 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    172     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    173     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     177if( cond )
    174178printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n",
    175179__FUNCTION__, this->process->pid, this->trdid,
     
    196200#if DEBUG_RWLOCK_TYPE
    197201thread_t * this = CURRENT_THREAD;
    198 uint32_t lock_type = lock->lock.type;
    199 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    200     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    201     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     202uint32_t   lock_type = lock->lock.type;
     203bool_t     cond = (lock_type == DEBUG_RWLOCK_TYPE) &&
     204                  (((local_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     205                    (lock == (rwlock_t*)DEBUG_RWLOCK_PTR)) ||
     206                   ((DEBUG_RWLOCK_CXY == 0) &&
     207                    (DEBUG_RWLOCK_PTR == 0)));
     208#endif
     209
     210#if DEBUG_RWLOCK_TYPE
     211if( cond )
    202212printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    203213__FUNCTION__, this->process->pid, this->trdid,
     
    213223
    214224#if DEBUG_RWLOCK_TYPE
    215 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    216     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    217     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     225if( cond )
    218226printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    219227__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    237245
    238246#if DEBUG_RWLOCK_TYPE
    239 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    240     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    241     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     247if( cond )
    242248printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    243249__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    272278#if DEBUG_RWLOCK_TYPE
    273279thread_t * this = CURRENT_THREAD;
    274 uint32_t lock_type = lock->lock.type;
    275 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    276     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    277     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     280uint32_t   lock_type = lock->lock.type;
     281bool_t     cond = (lock_type == DEBUG_RWLOCK_TYPE) &&
     282                  (((local_cxy == (cxt_t)DEBUG_RWLOCK_CXY) &&
     283                    (lock == (rwlock_t*)DEBUG_RWLOCK_PTR)) ||
     284                   ((DEBUG_RWLOCK_CXY == 0) &&
     285                    (DEBUG_RWLOCK_PTR == 0)));
     286#endif
     287
     288#if DEBUG_RWLOCK_TYPE
     289if( cond )
    278290printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n",
    279291__FUNCTION__, this->process->pid, this->trdid,
     
    288300
    289301#if DEBUG_RWLOCK_TYPE
    290 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    291     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    292     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     302if( cond )
    293303printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    294304__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
     
    311321
    312322#if DEBUG_RWLOCK_TYPE
    313 if( (lock_type      == DEBUG_RWLOCK_TYPE) &&
    314     ((intptr_t)lock == DEBUG_RWLOCK_PTR ) &&
    315     (local_cxy      == DEBUG_RWLOCK_CXY ) )
     323if( cond )
    316324printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n",
    317325__FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid,
  • trunk/kernel/libk/xlist.h

    r657 r666  
    175175 ***************************************************************************
    176176 * @ root_xp   :  extended pointer on the root xlist_entry_t
    177 xixi **************************************************************************/
     177 **************************************************************************/
    178178static inline void xlist_root_init( xptr_t root_xp )
    179179{
     
    321321
    322322/***************************************************************************
    323  * This debug function displays all entries of an xlist.
     323 * This debug function displays <max> entries of an xlist.
    324324 ***************************************************************************
    325325 * @ root_xp : extended pointer on the root xlist_entry_t.
Note: See TracChangeset for help on using the changeset viewer.