Changeset 666
- Timestamp:
- Oct 10, 2020, 5:27:12 PM (4 years ago)
- Location:
- trunk/kernel/libk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/bits.h
r657 r666 229 229 * This function takes a positive integer <val> as input argument, and returns the smallest 230 230 * 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. 232 232 ********************************************************************************************* 233 233 * @ val : value to analyse -
trunk/kernel/libk/busylock.c
r624 r666 1 1 /* 2 * busylock.c - local kernel -busy waiting lock implementation.2 * busylock.c - local kernel busy waiting lock implementation. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 45 45 lock->type = type; 46 46 47 #if DEBUG_BUSYLOCK 47 #if DEBUG_BUSYLOCK_TYPE 48 48 xlist_entry_init( XPTR( local_cxy , &lock->xlist ) ); 49 49 #endif -
trunk/kernel/libk/busylock.h
r624 r666 2 2 * busylock.h: local kernel busy-waiting lock definition. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 72 72 reg_t save_sr; /*! SR value */ 73 73 74 #if DEBUG_BUSYLOCK 74 #if DEBUG_BUSYLOCK_TYPE 75 75 xlist_entry_t xlist; /*! member of list of locks taken by same thread */ 76 76 #endif -
trunk/kernel/libk/queuelock.c
r629 r666 47 47 #if DEBUG_QUEUELOCK_TYPE 48 48 thread_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", 49 bool_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))); 54 if( cond ) printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 53 55 __FUNCTION__, this->process->pid, this->trdid, 54 56 lock_type_str[type], local_cxy, lock ); … … 70 72 #if DEBUG_QUEUELOCK_TYPE 71 73 uint32_t lock_type = lock->lock.type; 74 bool_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))); 72 79 #endif 73 80 … … 77 84 78 85 #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", 86 if( cond ) printk("\n[%s ] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n", 83 87 __FUNCTION__, this->process->pid, this->trdid, 84 88 lock_type_str[lock_type], local_cxy, lock ); … … 104 108 105 109 #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", 110 if( cond ) printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n", 110 111 __FUNCTION__, this->process->pid, this->trdid, 111 112 lock_type_str[lock_type], local_cxy, lock ); … … 132 133 uint32_t lock_type = lock->lock.type; 133 134 thread_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", 135 bool_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 143 if( cond ) printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n", 138 144 __FUNCTION__, this->process->pid, this->trdid, 139 145 lock_type_str[lock_type], local_cxy, lock ); … … 150 156 151 157 #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", 158 if( cond ) printk("\n[%s] thread[%x,%x] UNBLOCK thread [%x,%x] / q_lock %s [%x,%x]\n", 156 159 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, 157 160 lock_type_str[lock_type], local_cxy, lock ); -
trunk/kernel/libk/queuelock.h
r563 r666 41 41 * and a thread T' executing the release() function, the "queuelock" is protected 42 42 * by a "busylock" used by these two access functions. 43 * WARNING: this queuelock is NOT registered in the thread "local_locks" field.44 43 ******************************************************************************************/ 45 44 -
trunk/kernel/libk/remote_buf.c
r657 r666 31 31 #include <remote_buf.h> 32 32 33 ///////////////////////////////////////// //34 error_t remote_buf_ create( xptr_t buf_xp,35 33 ///////////////////////////////////////// 34 error_t remote_buf_init( xptr_t buf_xp, 35 uint32_t size ) 36 36 { 37 37 kmem_req_t req; … … 42 42 43 43 // 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 ) 45 49 { 46 50 req.type = KMEM_PPM; … … 48 52 req.flags = AF_NONE; 49 53 data = kmem_remote_alloc( buf_cxy , &req ); 54 55 if( data == NULL ) return -1; 50 56 } 51 57 else … … 55 61 req.flags = AF_NONE; 56 62 data = kmem_remote_alloc( buf_cxy , &req ); 57 } 58 59 if( data == NULL ) return -1;63 64 if( data == NULL ) return -1; 65 } 60 66 61 67 // initialize buffer descriptor … … 68 74 return 0; 69 75 70 } // end remote_buf_ create()76 } // end remote_buf_init() 71 77 72 78 ///////////////////////////////////////// … … 78 84 cxy_t buf_cxy = GET_CXY( buf_xp ); 79 85 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 ) 82 94 { 83 95 req.type = KMEM_PPM; -
trunk/kernel/libk/remote_buf.h
r657 r666 32 32 * This structure and the associated access functions define a remotely accessible, 33 33 * kernel buffer, handled as a single-reader & single-writer FIFO. 34 * Each buffer slot contains one byte, and the number of slots is dynamically35 * d efined 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. 38 38 * 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). 41 41 * - the "ptw" field defines the first empty slot (for write). 42 42 * - the "ptr" field defines the first non empty slot (for read). … … 58 58 * argument. It allocates memory for the data, as defined by the <size> argument, 59 59 * and initializes the buffer as empty. It must be called by a local thread. 60 * No memory is allocated if <size> value is 0. 60 61 ************************************************************************************ 61 62 * @ 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. 64 65 ***********************************************************************************/ 65 error_t remote_buf_ create( xptr_t buf_xp,66 66 error_t remote_buf_init( xptr_t buf_xp, 67 uint32_t size ); 67 68 68 69 /************************************************************************************ -
trunk/kernel/libk/remote_busylock.c
r624 r666 2 2 * remote_busylock.c - remote kernel busy-waiting lock implementation. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 50 50 hal_remote_s32( XPTR( lock_cxy , &lock_ptr->type ) , type ); 51 51 52 #if DEBUG_BUSYLOCK 52 #if DEBUG_BUSYLOCK_TYPE 53 53 xlist_entry_init( XPTR( lock_cxy , &lock_ptr->xlist ) ); 54 54 #endif … … 85 85 hal_fence(); 86 86 87 #if DEBUG_BUSYLOCK 87 #if DEBUG_BUSYLOCK_TYPE 88 88 uint32_t type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) ); 89 89 if( type != LOCK_CHDEV_TXT0 ) … … 93 93 xlist_add_last( root_xp , XPTR( lock_cxy , &lock_ptr->xlist ) ); 94 94 } 95 #endif 96 97 #if( DEBUG_BUSYLOCK & 1 ) 98 if( (type != LOCK_CHDEV_TXT0) && 95 if( (type == DEBUG_BUSYLOCK_TYPE) && 99 96 (this->process->pid == DEBUG_BUSYLOCK_PID) && 100 (this->trdid == DEBUG_BUSYLOCK_TRDID) )97 (this->trdid == DEBUG_BUSYLOCK_TRDID) ) 101 98 { 102 99 printk("\n[%s] thread[%x,%x] ACQUIRE lock %s\n", … … 128 125 hal_fence(); 129 126 130 #if DEBUG_BUSYLOCK 127 #if DEBUG_BUSYLOCK_TYPE 131 128 uint32_t type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->type ) ); 132 129 if( type != LOCK_CHDEV_TXT0 ) … … 135 132 xlist_unlink( XPTR( lock_cxy , &lock_ptr->xlist ) ); 136 133 } 137 #endif 138 139 #if( DEBUG_BUSYLOCK & 1 ) 140 if( (type != LOCK_CHDEV_TXT0) && 134 if( (type == DEBUG_BUSYLOCK_TYPE) && 141 135 (this->process->pid == DEBUG_BUSYLOCK_PID) && 142 (this->trdid == DEBUG_BUSYLOCK_TRDID) )136 (this->trdid == DEBUG_BUSYLOCK_TRDID) ) 143 137 { 144 138 printk("\n[%s] thread[%x,%x] RELEASE lock %s\n", -
trunk/kernel/libk/remote_busylock.h
r624 r666 2 2 * remote_busylock.h: remote kernel busy-waiting lock definition. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 74 74 reg_t save_sr; /*! SR value */ 75 75 76 #if DEBUG_BUSYLOCK 76 #if DEBUG_BUSYLOCK_TYPE 77 77 xlist_entry_t xlist; /*! member of list of locks taken by same thread */ 78 78 #endif -
trunk/kernel/libk/remote_queuelock.c
r629 r666 56 56 #if DEBUG_QUEUELOCK_TYPE 57 57 thread_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", 58 bool_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))); 63 if( cond )printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 62 64 __FUNCTION__, this->process->pid, this->trdid, 63 65 lock_type_str[type], lock_cxy, lock_ptr ); … … 70 72 { 71 73 thread_t * this = CURRENT_THREAD; 72 73 // check calling thread can yield74 thread_assert_can_yield( this , __FUNCTION__ );75 74 76 75 // get lock cluster and local pointer … … 78 77 remote_queuelock_t * lock_ptr = GET_PTR( lock_xp ); 79 78 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 83 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 84 bool_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))); 82 89 #endif 83 90 … … 93 100 94 101 #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", 102 if( cond ) printk("\n[%s] thread[%x,%x] BLOCK on q_lock %s [%x,%x]\n", 99 103 __FUNCTION__, this->process->pid, this->trdid, 100 104 lock_type_str[lock_type], lock_cxy, lock_ptr ); … … 121 125 122 126 #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", 127 if( cond ) printk("\n[%s] thread[%x,%x] ACQUIRE q_lock %s [%x,%x]\n", 127 128 __FUNCTION__, this->process->pid, this->trdid, 128 129 lock_type_str[lock_type], lock_cxy, lock_ptr ); … … 149 150 remote_queuelock_t * lock_ptr = GET_PTR( lock_xp ); 150 151 152 #if DEBUG_QUEUELOCK_TYPE 153 thread_t * this = CURRENT_THREAD; 154 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 155 bool_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 151 162 // build extended pointer on busylock protecting queuelock 152 163 xptr_t busylock_xp = XPTR( lock_cxy , &lock_ptr->lock ); … … 156 167 157 168 #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", 169 if( cond ) printk("\n[%s] thread[%x,%x] RELEASE q_lock %s [%x,%x]\n", 164 170 __FUNCTION__, this->process->pid, this->trdid, 165 171 lock_type_str[lock_type], lock_cxy, lock_ptr ); … … 179 185 180 186 #if DEBUG_QUEUELOCK_TYPE 181 if( (lock_type == DEBUG_QUEUELOCK_TYPE) && 182 (lock_ptr == DEBUG_QUEUELOCK_PTR ) && 183 (lock_cxy == DEBUG_QUEUELOCK_CXY ) ) 187 if( cond ) 184 188 { 185 189 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); -
trunk/kernel/libk/remote_queuelock.h
r563 r666 41 41 * and a thread T' executing the release() function, the "remote_queuelock" is protected 42 42 * by a "remote_busylock" used by these two access functions. 43 * WARNING: this remote_queuelock is NOT registered in the thread "remote_locks" field.44 43 ******************************************************************************************/ 45 44 … … 59 58 /******************************************************************************************* 60 59 * 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. 62 61 * This type is actually stored in the associated busylock descriptor. 63 62 ******************************************************************************************* -
trunk/kernel/libk/remote_rwlock.c
r629 r666 55 55 #if DEBUG_RWLOCK_TYPE 56 56 thread_t * this = CURRENT_THREAD; 57 if( (type == DEBUG_RWLOCK_TYPE) && 58 ((intptr_t)lock_ptr == DEBUG_RWLOCK_PTR ) && 59 (lock_cxy == DEBUG_RWLOCK_CXY ) ) 57 bool_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))); 62 if( cond ) 60 63 printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 61 64 __FUNCTION__, this->process->pid, this->trdid, … … 78 81 79 82 #if DEBUG_RWLOCK_TYPE 80 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 83 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 84 bool_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))); 89 xptr_t wr_root_xp = XPTR( lock_cxy , &lock_ptr->wr_xroot ); 81 90 #endif 82 91 … … 95 104 96 105 #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", 106 if( cond ) 107 printk("\n[%s] thread[%x,%x] READ BLOCK on %s [%x,%x]\n" 108 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 101 109 __FUNCTION__, this->process->pid, this->trdid, 102 110 lock_type_str[lock_type], lock_cxy, lock_ptr, 103 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 111 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 112 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 104 113 #endif 105 114 // get pointer on calling thread … … 128 137 129 138 #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", 139 if( cond ) 140 printk("\n[%s] thread[%x,%x] READ ACQUIRE %s [%x,%x]\n" 141 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 134 142 __FUNCTION__, this->process->pid, this->trdid, 135 143 lock_type_str[lock_type], lock_cxy, lock_ptr, 136 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 144 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 145 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 137 146 #endif 138 147 … … 155 164 156 165 #if DEBUG_RWLOCK_TYPE 157 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 166 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 167 bool_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))); 172 xptr_t rd_root_xp = XPTR( lock_cxy , &lock_ptr->rd_xroot ); 158 173 #endif 159 174 … … 172 187 173 188 #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", 189 if( cond ) 190 printk("\n[%s] thread[%x,%x] WRITE BLOCK on %s [%x,%x]\n" 191 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 178 192 __FUNCTION__, this->process->pid, this->trdid, 179 193 lock_type_str[lock_type], lock_cxy, lock_ptr, 180 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 194 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 195 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 181 196 #endif 182 197 … … 204 219 205 220 #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", 221 if( cond ) 222 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE %s [%x,%x]\n" 223 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 210 224 __FUNCTION__, this->process->pid, this->trdid, 211 225 lock_type_str[lock_type], lock_cxy, lock_ptr, 212 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 226 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 227 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 213 228 #endif 214 229 … … 244 259 thread_t * this = CURRENT_THREAD; 245 260 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 261 bool_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))); 246 266 xptr_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 270 if( cond ) 271 printk("\n[%s] thread[%x,%x] READ RELEASE %s [%x,%x]\n" 272 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 251 273 __FUNCTION__, this->process->pid, this->trdid, 252 274 lock_type_str[lock_type], lock_cxy, lock_ptr, 253 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 275 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 276 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 254 277 #endif 255 278 … … 270 293 271 294 #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 ) ) 295 if( cond ) 275 296 { 276 297 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 303 324 304 325 #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 ) ) 326 if( cond ) 308 327 { 309 328 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 349 368 thread_t * this = CURRENT_THREAD; 350 369 uint32_t lock_type = hal_remote_l32( XPTR( lock_cxy , &lock_ptr->lock.type ) ); 370 bool_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))); 351 375 xptr_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 379 if( cond ) 380 printk("\n[%s] thread[%x,%x] WRITE RELEASE %s [%x,%x]\n" 381 " taken %d / count %d / wr_empty %d / rd_empty %d\n", 356 382 __FUNCTION__, this->process->pid, this->trdid, 357 383 lock_type_str[lock_type], lock_cxy, lock_ptr, 358 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ) ); 384 hal_remote_l32( taken_xp ), hal_remote_l32( count_xp ), 385 xlist_is_empty( wr_root_xp ), xlist_is_empty( rd_root_xp ) ); 359 386 #endif 360 387 … … 374 401 375 402 #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 ) ) 403 if( cond ) 379 404 { 380 405 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); … … 406 431 407 432 #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 ) ) 433 if( cond ) 411 434 { 412 435 trdid_t trdid = hal_remote_l32( XPTR( thread_cxy , &thread_ptr->trdid ) ); -
trunk/kernel/libk/rwlock.c
r629 r666 52 52 #if DEBUG_RWLOCK_TYPE 53 53 thread_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", 54 bool_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))); 59 if( cond ) printk("\n[%s] thread[%x,%x] initialise lock %s [%x,%x]\n", 58 60 __FUNCTION__, this->process->pid, this->trdid, 59 61 lock_type_str[type], local_cxy, lock ); … … 74 76 75 77 #if DEBUG_RWLOCK_TYPE 76 uint32_t lock_type = lock->lock.type; 78 uint32_t lock_type = lock->lock.type; 79 bool_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))); 77 84 #endif 78 85 … … 82 89 83 90 #if DEBUG_RWLOCK_TYPE 84 if( (lock_type == DEBUG_RWLOCK_TYPE) && 85 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 86 (local_cxy == DEBUG_RWLOCK_CXY ) ) 91 if( cond ) 87 92 printk("\n[%s] thread[%x,%x] READ BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 88 93 __FUNCTION__, this->process->pid, this->trdid, … … 109 114 110 115 #if DEBUG_RWLOCK_TYPE 111 if( (lock_type == DEBUG_RWLOCK_TYPE) && 112 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 113 (local_cxy == DEBUG_RWLOCK_CXY ) ) 116 if( cond ) 114 117 printk("\n[%s] thread[%x,%x] READ ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 115 118 __FUNCTION__, this->process->pid, this->trdid, … … 134 137 135 138 #if DEBUG_RWLOCK_TYPE 136 uint32_t lock_type = lock->lock.type; 139 uint32_t lock_type = lock->lock.type; 140 bool_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))); 137 145 #endif 138 146 … … 142 150 143 151 #if DEBUG_RWLOCK_TYPE 144 if( (lock_type == DEBUG_RWLOCK_TYPE) && 145 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 146 (local_cxy == DEBUG_RWLOCK_CXY ) ) 152 if( cond ) 147 153 printk("\n[%s] thread[%x,%x] WRITE BLOCK on rwlock %s [%x,%x] / taken %d / count %d\n", 148 154 __FUNCTION__, this->process->pid, this->trdid, … … 169 175 170 176 #if DEBUG_RWLOCK_TYPE 171 if( (lock_type == DEBUG_RWLOCK_TYPE) && 172 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 173 (local_cxy == DEBUG_RWLOCK_CXY ) ) 177 if( cond ) 174 178 printk("\n[%s] thread[%x,%x] WRITE ACQUIRE rwlock %s [%x,%x] / taken %d / count %d\n", 175 179 __FUNCTION__, this->process->pid, this->trdid, … … 196 200 #if DEBUG_RWLOCK_TYPE 197 201 thread_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 ) ) 202 uint32_t lock_type = lock->lock.type; 203 bool_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 211 if( cond ) 202 212 printk("\n[%s] thread[%x,%x] READ RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 203 213 __FUNCTION__, this->process->pid, this->trdid, … … 213 223 214 224 #if DEBUG_RWLOCK_TYPE 215 if( (lock_type == DEBUG_RWLOCK_TYPE) && 216 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 217 (local_cxy == DEBUG_RWLOCK_CXY ) ) 225 if( cond ) 218 226 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 219 227 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, … … 237 245 238 246 #if DEBUG_RWLOCK_TYPE 239 if( (lock_type == DEBUG_RWLOCK_TYPE) && 240 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 241 (local_cxy == DEBUG_RWLOCK_CXY ) ) 247 if( cond ) 242 248 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 243 249 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, … … 272 278 #if DEBUG_RWLOCK_TYPE 273 279 thread_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 ) ) 280 uint32_t lock_type = lock->lock.type; 281 bool_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 289 if( cond ) 278 290 printk("\n[%s] thread[%x,%x] WRITE RELEASE rwlock %s [%x,%x] / taken %d / count %d\n", 279 291 __FUNCTION__, this->process->pid, this->trdid, … … 288 300 289 301 #if DEBUG_RWLOCK_TYPE 290 if( (lock_type == DEBUG_RWLOCK_TYPE) && 291 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 292 (local_cxy == DEBUG_RWLOCK_CXY ) ) 302 if( cond ) 293 303 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 294 304 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, … … 311 321 312 322 #if DEBUG_RWLOCK_TYPE 313 if( (lock_type == DEBUG_RWLOCK_TYPE) && 314 ((intptr_t)lock == DEBUG_RWLOCK_PTR ) && 315 (local_cxy == DEBUG_RWLOCK_CXY ) ) 323 if( cond ) 316 324 printk("\n[%s] thread[%x,%x] UNBLOCK thread[%x,%x] / rwlock %s [%x,%x]\n", 317 325 __FUNCTION__, this->process->pid, this->trdid, thread->process->pid, thread->trdid, -
trunk/kernel/libk/xlist.h
r657 r666 175 175 *************************************************************************** 176 176 * @ root_xp : extended pointer on the root xlist_entry_t 177 xixi**************************************************************************/177 **************************************************************************/ 178 178 static inline void xlist_root_init( xptr_t root_xp ) 179 179 { … … 321 321 322 322 /*************************************************************************** 323 * This debug function displays allentries of an xlist.323 * This debug function displays <max> entries of an xlist. 324 324 *************************************************************************** 325 325 * @ root_xp : extended pointer on the root xlist_entry_t.
Note: See TracChangeset
for help on using the changeset viewer.