Changeset 408 for trunk/kernel/kern/chdev.c
- Timestamp:
- Dec 5, 2017, 4:20:07 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/chdev.c
r407 r408 120 120 uint32_t lid; // core running the server thread local index 121 121 xptr_t lock_xp; // extended pointer on lock protecting the chdev queue 122 uint32_t modified; // non zero if the server thread state was modified122 uint32_t different; // non zero if server thread core != client thread core 123 123 uint32_t save_sr; // for critical section 124 124 … … 152 152 lid = hal_remote_lw( XPTR( chdev_cxy , &core_ptr->lid ) ); 153 153 154 // enter critical section 154 // compute server core != thread core 155 different = (lid != this->core->lid) || (local_cxy != chdev_cxy); 156 157 // enter critical section to make atomic : 158 // (1) client blocking 159 // (2) client registration in server queue 160 // (3) IPI to force server scheduling 161 // (4) descheduling 162 // ... in this order 155 163 hal_disable_irq( &save_sr ); 164 165 // block current thread 166 thread_block( CURRENT_THREAD , THREAD_BLOCKED_IO ); 156 167 157 168 // register client thread in waiting queue … … 160 171 remote_spinlock_unlock( lock_xp ); 161 172 162 // unblock server thread 163 modified = thread_unblock( XPTR( chdev_cxy , server_ptr ), THREAD_BLOCKED_DEV_QUEUE ); 164 165 // send IPI to core running the server thread 166 if( modified ) dev_pic_send_ipi( chdev_cxy , lid ); 173 // send IPI to core running the server thread if required 174 if( different ) dev_pic_send_ipi( chdev_cxy , lid ); 167 175 168 // block client thread169 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" );170 171 176 chdev_dmsg("\n[DBG] %s : core[%x,%d] (thread %s) deschedules / cycle %d\n", 172 177 __FUNCTION__, local_cxy, this->core->lid, thread_type_str(this->type) , hal_time_stamp() ); 173 178 174 thread_block( CURRENT_THREAD , THREAD_BLOCKED_IO ); 175 sched_yield(); 179 // deschedule 180 assert( thread_can_yield( this ) , __FUNCTION__ , "illegal sched_yield\n" ); 181 sched_yield("blocked on I/O"); 176 182 177 183 chdev_dmsg("\n[DBG] %s : core[%x,%d] (thread %s) resumes / cycle %d\n", … … 217 223 __FUNCTION__ , server , hal_time_stamp() ); 218 224 219 // block and deschedule 220 thread_block( server , THREAD_BLOCKED_DEV_QUEUE ); 221 sched_yield(); 225 // deschedule 226 sched_yield("I/O queue empty"); 222 227 223 228 chdev_dmsg("\n[DBG] %s : thread %x resume /cycle %d\n",
Note: See TracChangeset
for help on using the changeset viewer.