Changeset 592 for trunk/kernel/kern
- Timestamp:
- Nov 1, 2018, 7:27:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/scheduler.c
r583 r592 145 145 146 146 //////////////////////////////////////////////////////////////////////////////////////////// 147 // This static function is the only function that can actually delete a thread. 147 // This static function is the only function that can actually delete a thread, 148 // and the associated process descriptor, if required. 148 149 // It is private, because it is called by the sched_yield() public function. 149 150 // It scan all threads attached to a given scheduler, and executes the relevant 150 151 // actions for two types of pending requests: 152 // 151 153 // - REQ_ACK : it checks that target thread is blocked, decrements the response counter 152 154 // to acknowledge the client thread, and reset the pending request. … … 177 179 sched = &core->scheduler; 178 180 181 // take the lock protecting sheduler state 182 busylock_acquire( &sched->lock ); 183 179 184 ////// scan user threads to handle both ACK and DELETE requests 180 185 root = &sched->u_root; … … 193 198 194 199 // check thread blocked 195 assert( (thread->blocked & THREAD_BLOCKED_GLOBAL) , 196 "thread not blocked" ); 200 assert( (thread->blocked & THREAD_BLOCKED_GLOBAL) , "thread not blocked" ); 197 201 198 202 // decrement response counter … … 211 215 // get thread ltid 212 216 ltid = LTID_FROM_TRDID( thread->trdid); 213 214 // take the lock protecting th_tbl[]215 rwlock_wr_acquire( &process->th_lock );216 217 // take the lock protecting sheduler state218 busylock_acquire( &sched->lock );219 217 220 218 // update scheduler state … … 238 236 } 239 237 240 // release the lock protecting sheduler state241 busylock_release( &sched->lock );242 243 // get number of threads in local process244 count = process->th_nr;245 246 238 // check th_nr value 247 assert( ( count> 0) , "process th_nr cannot be 0\n" );239 assert( (process->th_nr > 0) , "process th_nr cannot be 0\n" ); 248 240 249 241 // remove thread from process th_tbl[] 250 242 process->th_tbl[ltid] = NULL; 251 process->th_nr = count - 1;243 hal_atomic_add( &process->th_nr , - 1 ); 252 244 253 // release the lock protecting th_tbl[]254 rwlock_wr_release( &process->th_lock );255 256 245 // release memory allocated for thread descriptor 257 246 thread_destroy( thread ); … … 299 288 // get thread ltid 300 289 ltid = LTID_FROM_TRDID( thread->trdid); 301 302 // take the lock protecting th_tbl[]303 rwlock_wr_acquire( &process_zero.th_lock );304 305 // take lock protecting sheduler state306 busylock_acquire( &sched->lock );307 290 308 291 // update scheduler state … … 326 309 } 327 310 328 // release lock protecting scheduler state329 busylock_release( &sched->lock );330 331 311 // get number of threads in local kernel process 332 312 count = process_zero.th_nr; 333 313 334 314 // check th_nr value 335 assert( ( count> 0) , "kernel process th_nr cannot be 0\n" );315 assert( (process_zero.th_nr > 0) , "kernel process th_nr cannot be 0\n" ); 336 316 337 317 // remove thread from process th_tbl[] 338 318 process_zero.th_tbl[ltid] = NULL; 339 process_zero.th_nr = count - 1;319 hal_atomic_add( &process_zero.th_nr , - 1 ); 340 320 341 // release the lock protecting th_tbl[]342 rwlock_wr_release( &process_zero.th_lock );343 344 321 // delete thread descriptor 345 322 thread_destroy( thread ); … … 353 330 } 354 331 } 332 333 // release the lock protecting sheduler state 334 busylock_release( &sched->lock ); 335 355 336 } // end sched_handle_signals() 356 337
Note: See TracChangeset
for help on using the changeset viewer.