Changeset c0bff5e in rtems
- Timestamp:
- 05/15/14 08:31:22 (10 years ago)
- Branches:
- 4.11, 5, master
- Children:
- b532bb2c
- Parents:
- b4bdbcf
- git-author:
- Sebastian Huber <sebastian.huber@…> (05/15/14 08:31:22)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (05/15/14 10:18:49)
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/score/include/rtems/score/schedulersmpimpl.h
rb4bdbcf rc0bff5e 42 42 * 43 43 * State transitions are triggered via basic operations 44 * - _Scheduler_SMP_Enqueue_ordered(), and 44 * - _Scheduler_SMP_Enqueue_ordered(), 45 * - _Scheduler_SMP_Enqueue_scheduled_ordered(), and 45 46 * - _Scheduler_SMP_Block(). 46 47 * … … 296 297 typedef void ( *Scheduler_SMP_Enqueue )( 297 298 Scheduler_Context *context, 298 Thread_Control *thread_to_enqueue, 299 bool has_processor_allocated 299 Thread_Control *thread_to_enqueue 300 300 ); 301 301 … … 433 433 * @brief Enqueues a thread according to the specified order function. 434 434 * 435 * The thread must not be in the scheduled state. 436 * 435 437 * @param[in] context The scheduler instance context. 436 438 * @param[in] thread The thread to enqueue. 437 * @param[in] has_processor_allocated The thread has a processor allocated. 439 * @param[in] order The order function. 440 * @param[in] insert_ready Function to insert a node into the set of ready 441 * nodes. 442 * @param[in] insert_scheduled Function to insert a node into the set of 443 * scheduled nodes. 444 * @param[in] move_from_scheduled_to_ready Function to move a node from the set 445 * of scheduled nodes to the set of ready nodes. 446 */ 447 static inline void _Scheduler_SMP_Enqueue_ordered( 448 Scheduler_Context *context, 449 Thread_Control *thread, 450 Chain_Node_order order, 451 Scheduler_SMP_Insert insert_ready, 452 Scheduler_SMP_Insert insert_scheduled, 453 Scheduler_SMP_Move move_from_scheduled_to_ready 454 ) 455 { 456 Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); 457 Thread_Control *lowest_scheduled = 458 _Scheduler_SMP_Get_lowest_scheduled( self ); 459 460 _Assert( lowest_scheduled != NULL); 461 462 /* 463 * NOTE: Do not exchange parameters to do the negation of the order check. 464 */ 465 if ( ( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) { 466 Scheduler_SMP_Node *lowest_scheduled_node = 467 _Scheduler_SMP_Node_get( lowest_scheduled ); 468 469 _Scheduler_SMP_Node_change_state( 470 lowest_scheduled_node, 471 SCHEDULER_SMP_NODE_READY 472 ); 473 _Scheduler_SMP_Allocate_processor( self, thread, lowest_scheduled ); 474 ( *insert_scheduled )( &self->Base, thread ); 475 ( *move_from_scheduled_to_ready )( &self->Base, lowest_scheduled ); 476 } else { 477 ( *insert_ready )( &self->Base, thread ); 478 } 479 } 480 481 /** 482 * @brief Enqueues a scheduled thread according to the specified order 483 * function. 484 * 485 * @param[in] context The scheduler instance context. 486 * @param[in] thread The thread to enqueue. 438 487 * @param[in] order The order function. 439 488 * @param[in] get_highest_ready Function to get the highest ready node. … … 444 493 * @param[in] move_from_ready_to_scheduled Function to move a node from the set 445 494 * of ready nodes to the set of scheduled nodes. 446 * @param[in] move_from_scheduled_to_ready Function to move a node from the set447 * of scheduled nodes to the set of ready nodes.448 495 */ 449 static inline void _Scheduler_SMP_Enqueue_ ordered(496 static inline void _Scheduler_SMP_Enqueue_scheduled_ordered( 450 497 Scheduler_Context *context, 451 498 Thread_Control *thread, 452 bool has_processor_allocated,453 499 Chain_Node_order order, 454 500 Scheduler_SMP_Get_highest_ready get_highest_ready, 455 501 Scheduler_SMP_Insert insert_ready, 456 502 Scheduler_SMP_Insert insert_scheduled, 457 Scheduler_SMP_Move move_from_ready_to_scheduled, 458 Scheduler_SMP_Move move_from_scheduled_to_ready 503 Scheduler_SMP_Move move_from_ready_to_scheduled 459 504 ) 460 505 { 461 506 Scheduler_SMP_Context *self = _Scheduler_SMP_Get_self( context ); 462 507 Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread ); 463 464 if ( has_processor_allocated) { 465 Thread_Control *highest_ready = ( *get_highest_ready )( &self->Base ); 466 467 _Assert( highest_ready != NULL); 468 469 /* 470 * The thread has been extracted from the scheduled chain. We have to 471 * place it now on the scheduled or ready chain. 472 * 473 * NOTE: Do not exchange parameters to do the negation of the order check. 474 */ 475 if ( !( *order )( &thread->Object.Node, &highest_ready->Object.Node ) ) { 476 _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); 477 _Scheduler_SMP_Allocate_processor( self, highest_ready, thread ); 478 ( *insert_ready )( &self->Base, thread ); 479 ( *move_from_ready_to_scheduled )( &self->Base, highest_ready ); 480 } else { 481 _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_SCHEDULED ); 482 ( *insert_scheduled )( &self->Base, thread ); 483 } 508 Thread_Control *highest_ready = ( *get_highest_ready )( &self->Base ); 509 510 _Assert( highest_ready != NULL); 511 512 /* 513 * The thread has been extracted from the scheduled chain. We have to place 514 * it now on the scheduled or ready set. 515 * 516 * NOTE: Do not exchange parameters to do the negation of the order check. 517 */ 518 if ( !( *order )( &thread->Object.Node, &highest_ready->Object.Node ) ) { 519 _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); 520 _Scheduler_SMP_Allocate_processor( self, highest_ready, thread ); 521 ( *insert_ready )( &self->Base, thread ); 522 ( *move_from_ready_to_scheduled )( &self->Base, highest_ready ); 484 523 } else { 485 Thread_Control *lowest_scheduled = 486 _Scheduler_SMP_Get_lowest_scheduled( self ); 487 488 _Assert( lowest_scheduled != NULL); 489 490 if ( ( *order )( &thread->Object.Node, &lowest_scheduled->Object.Node ) ) { 491 Scheduler_SMP_Node *lowest_scheduled_node = 492 _Scheduler_SMP_Node_get( lowest_scheduled ); 493 494 _Scheduler_SMP_Node_change_state( 495 lowest_scheduled_node, 496 SCHEDULER_SMP_NODE_READY 497 ); 498 _Scheduler_SMP_Allocate_processor( self, thread, lowest_scheduled ); 499 ( *insert_scheduled )( &self->Base, thread ); 500 ( *move_from_scheduled_to_ready )( &self->Base, lowest_scheduled ); 501 } else { 502 _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); 503 ( *insert_ready )( &self->Base, thread ); 504 } 505 } 506 } 507 508 static inline void _Scheduler_SMP_Extract_from_scheduled( Thread_Control *thread ) 524 ( *insert_scheduled )( &self->Base, thread ); 525 } 526 } 527 528 static inline void _Scheduler_SMP_Extract_from_scheduled( 529 Thread_Control *thread 530 ) 509 531 { 510 532 _Chain_Extract_unprotected( &thread->Object.Node ); … … 564 586 } 565 587 588 static inline void _Scheduler_SMP_Unblock( 589 Scheduler_Context *context, 590 Thread_Control *thread, 591 Scheduler_SMP_Enqueue enqueue_fifo 592 ) 593 { 594 Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread ); 595 596 _Scheduler_SMP_Node_change_state( node, SCHEDULER_SMP_NODE_READY ); 597 598 ( *enqueue_fifo )( context, thread ); 599 } 600 566 601 static inline void _Scheduler_SMP_Change_priority( 567 602 Scheduler_Context *context, … … 572 607 Scheduler_SMP_Update update, 573 608 Scheduler_SMP_Enqueue enqueue_fifo, 574 Scheduler_SMP_Enqueue enqueue_lifo 609 Scheduler_SMP_Enqueue enqueue_lifo, 610 Scheduler_SMP_Enqueue enqueue_scheduled_fifo, 611 Scheduler_SMP_Enqueue enqueue_scheduled_lifo 575 612 ) 576 613 { 577 614 Scheduler_SMP_Node *node = _Scheduler_SMP_Node_get( thread ); 578 bool has_processor_allocated = node->state == SCHEDULER_SMP_NODE_SCHEDULED; 579 580 if ( has_processor_allocated ) { 615 616 if ( node->state == SCHEDULER_SMP_NODE_SCHEDULED ) { 581 617 _Scheduler_SMP_Extract_from_scheduled( thread ); 618 619 ( *update )( context, &node->Base, new_priority ); 620 621 if ( prepend_it ) { 622 ( *enqueue_scheduled_lifo )( context, thread ); 623 } else { 624 ( *enqueue_scheduled_fifo )( context, thread ); 625 } 582 626 } else { 583 627 ( *extract_from_ready )( context, thread ); 584 } 585 586 ( *update )( context, &node->Base, new_priority ); 587 588 if ( prepend_it ) {589 ( *enqueue_lifo )( context, thread, has_processor_allocated );590 } else {591 ( *enqueue_fifo )( context, thread, has_processor_allocated );628 629 ( *update )( context, &node->Base, new_priority ); 630 631 if ( prepend_it ) { 632 ( *enqueue_lifo )( context, thread ); 633 } else { 634 ( *enqueue_fifo )( context, thread ); 635 } 592 636 } 593 637 } -
cpukit/score/src/schedulerprioritysmp.c
rb4bdbcf rc0bff5e 229 229 Scheduler_Context *context, 230 230 Thread_Control *thread, 231 bool has_processor_allocated,232 231 Chain_Node_order order, 233 232 Scheduler_SMP_Insert insert_ready, … … 238 237 context, 239 238 thread, 240 has_processor_allocated, 239 order, 240 insert_ready, 241 insert_scheduled, 242 _Scheduler_priority_SMP_Move_from_scheduled_to_ready 243 ); 244 } 245 246 static void _Scheduler_priority_SMP_Enqueue_lifo( 247 Scheduler_Context *context, 248 Thread_Control *thread 249 ) 250 { 251 _Scheduler_priority_SMP_Enqueue_ordered( 252 context, 253 thread, 254 _Scheduler_simple_Insert_priority_lifo_order, 255 _Scheduler_priority_SMP_Insert_ready_lifo, 256 _Scheduler_SMP_Insert_scheduled_lifo 257 ); 258 } 259 260 static void _Scheduler_priority_SMP_Enqueue_fifo( 261 Scheduler_Context *context, 262 Thread_Control *thread 263 ) 264 { 265 _Scheduler_priority_SMP_Enqueue_ordered( 266 context, 267 thread, 268 _Scheduler_simple_Insert_priority_fifo_order, 269 _Scheduler_priority_SMP_Insert_ready_fifo, 270 _Scheduler_SMP_Insert_scheduled_fifo 271 ); 272 } 273 274 static void _Scheduler_priority_SMP_Enqueue_scheduled_ordered( 275 Scheduler_Context *context, 276 Thread_Control *thread, 277 Chain_Node_order order, 278 Scheduler_SMP_Insert insert_ready, 279 Scheduler_SMP_Insert insert_scheduled 280 ) 281 { 282 _Scheduler_SMP_Enqueue_scheduled_ordered( 283 context, 284 thread, 241 285 order, 242 286 _Scheduler_priority_SMP_Get_highest_ready, 243 287 insert_ready, 244 288 insert_scheduled, 245 _Scheduler_priority_SMP_Move_from_ready_to_scheduled, 246 _Scheduler_priority_SMP_Move_from_scheduled_to_ready 247 ); 248 } 249 250 static void _Scheduler_priority_SMP_Enqueue_lifo( 251 Scheduler_Context *context, 252 Thread_Control *thread, 253 bool has_processor_allocated 254 ) 255 { 256 _Scheduler_priority_SMP_Enqueue_ordered( 257 context, 258 thread, 259 has_processor_allocated, 289 _Scheduler_priority_SMP_Move_from_ready_to_scheduled 290 ); 291 } 292 293 static void _Scheduler_priority_SMP_Enqueue_scheduled_lifo( 294 Scheduler_Context *context, 295 Thread_Control *thread 296 ) 297 { 298 _Scheduler_priority_SMP_Enqueue_scheduled_ordered( 299 context, 300 thread, 260 301 _Scheduler_simple_Insert_priority_lifo_order, 261 302 _Scheduler_priority_SMP_Insert_ready_lifo, … … 264 305 } 265 306 266 static void _Scheduler_priority_SMP_Enqueue_fifo( 267 Scheduler_Context *context, 268 Thread_Control *thread, 269 bool has_processor_allocated 270 ) 271 { 272 _Scheduler_priority_SMP_Enqueue_ordered( 273 context, 274 thread, 275 has_processor_allocated, 307 static void _Scheduler_priority_SMP_Enqueue_scheduled_fifo( 308 Scheduler_Context *context, 309 Thread_Control *thread 310 ) 311 { 312 _Scheduler_priority_SMP_Enqueue_scheduled_ordered( 313 context, 314 thread, 276 315 _Scheduler_simple_Insert_priority_fifo_order, 277 316 _Scheduler_priority_SMP_Insert_ready_fifo, … … 287 326 Scheduler_Context *context = _Scheduler_Get_context( scheduler ); 288 327 289 _Scheduler_priority_SMP_Enqueue_fifo( context, thread, false ); 328 _Scheduler_SMP_Unblock( 329 context, 330 thread, 331 _Scheduler_priority_SMP_Enqueue_fifo 332 ); 290 333 } 291 334 … … 307 350 _Scheduler_priority_SMP_Do_update, 308 351 _Scheduler_priority_SMP_Enqueue_fifo, 309 _Scheduler_priority_SMP_Enqueue_lifo 352 _Scheduler_priority_SMP_Enqueue_lifo, 353 _Scheduler_priority_SMP_Enqueue_scheduled_fifo, 354 _Scheduler_priority_SMP_Enqueue_scheduled_lifo 310 355 ); 311 356 } … … 322 367 323 368 _Scheduler_SMP_Extract_from_scheduled( thread ); 324 _Scheduler_priority_SMP_Enqueue_ fifo( context, thread, true);369 _Scheduler_priority_SMP_Enqueue_scheduled_fifo( context, thread ); 325 370 326 371 _ISR_Enable( level ); -
cpukit/score/src/schedulersimplesmp.c
rb4bdbcf rc0bff5e 165 165 Scheduler_Context *context, 166 166 Thread_Control *thread, 167 bool has_processor_allocated,168 167 Chain_Node_order order, 169 168 Scheduler_SMP_Insert insert_ready, … … 174 173 context, 175 174 thread, 176 has_processor_allocated, 175 order, 176 insert_ready, 177 insert_scheduled, 178 _Scheduler_simple_SMP_Move_from_scheduled_to_ready 179 ); 180 } 181 182 static void _Scheduler_simple_SMP_Enqueue_lifo( 183 Scheduler_Context *context, 184 Thread_Control *thread 185 ) 186 { 187 _Scheduler_simple_SMP_Enqueue_ordered( 188 context, 189 thread, 190 _Scheduler_simple_Insert_priority_lifo_order, 191 _Scheduler_simple_SMP_Insert_ready_lifo, 192 _Scheduler_SMP_Insert_scheduled_lifo 193 ); 194 } 195 196 static void _Scheduler_simple_SMP_Enqueue_fifo( 197 Scheduler_Context *context, 198 Thread_Control *thread 199 ) 200 { 201 _Scheduler_simple_SMP_Enqueue_ordered( 202 context, 203 thread, 204 _Scheduler_simple_Insert_priority_fifo_order, 205 _Scheduler_simple_SMP_Insert_ready_fifo, 206 _Scheduler_SMP_Insert_scheduled_fifo 207 ); 208 } 209 210 static void _Scheduler_simple_SMP_Enqueue_scheduled_ordered( 211 Scheduler_Context *context, 212 Thread_Control *thread, 213 Chain_Node_order order, 214 Scheduler_SMP_Insert insert_ready, 215 Scheduler_SMP_Insert insert_scheduled 216 ) 217 { 218 _Scheduler_SMP_Enqueue_scheduled_ordered( 219 context, 220 thread, 177 221 order, 178 222 _Scheduler_simple_SMP_Get_highest_ready, 179 223 insert_ready, 180 224 insert_scheduled, 181 _Scheduler_simple_SMP_Move_from_ready_to_scheduled, 182 _Scheduler_simple_SMP_Move_from_scheduled_to_ready 183 ); 184 } 185 186 static void _Scheduler_simple_SMP_Enqueue_lifo( 187 Scheduler_Context *context, 188 Thread_Control *thread, 189 bool has_processor_allocated 190 ) 191 { 192 _Scheduler_simple_SMP_Enqueue_ordered( 193 context, 194 thread, 195 has_processor_allocated, 225 _Scheduler_simple_SMP_Move_from_ready_to_scheduled 226 ); 227 } 228 229 static void _Scheduler_simple_SMP_Enqueue_scheduled_lifo( 230 Scheduler_Context *context, 231 Thread_Control *thread 232 ) 233 { 234 _Scheduler_simple_SMP_Enqueue_scheduled_ordered( 235 context, 236 thread, 196 237 _Scheduler_simple_Insert_priority_lifo_order, 197 238 _Scheduler_simple_SMP_Insert_ready_lifo, … … 200 241 } 201 242 202 static void _Scheduler_simple_SMP_Enqueue_fifo( 203 Scheduler_Context *context, 204 Thread_Control *thread, 205 bool has_processor_allocated 206 ) 207 { 208 _Scheduler_simple_SMP_Enqueue_ordered( 209 context, 210 thread, 211 has_processor_allocated, 243 static void _Scheduler_simple_SMP_Enqueue_scheduled_fifo( 244 Scheduler_Context *context, 245 Thread_Control *thread 246 ) 247 { 248 _Scheduler_simple_SMP_Enqueue_scheduled_ordered( 249 context, 250 thread, 212 251 _Scheduler_simple_Insert_priority_fifo_order, 213 252 _Scheduler_simple_SMP_Insert_ready_fifo, … … 223 262 Scheduler_Context *context = _Scheduler_Get_context( scheduler ); 224 263 225 _Scheduler_simple_SMP_Enqueue_fifo( context, thread, false ); 264 _Scheduler_SMP_Unblock( 265 context, 266 thread, 267 _Scheduler_simple_SMP_Enqueue_fifo 268 ); 226 269 } 227 270 … … 243 286 _Scheduler_simple_SMP_Do_update, 244 287 _Scheduler_simple_SMP_Enqueue_fifo, 245 _Scheduler_simple_SMP_Enqueue_lifo 288 _Scheduler_simple_SMP_Enqueue_lifo, 289 _Scheduler_simple_SMP_Enqueue_scheduled_fifo, 290 _Scheduler_simple_SMP_Enqueue_scheduled_lifo 246 291 ); 247 292 } … … 258 303 259 304 _Scheduler_SMP_Extract_from_scheduled( thread ); 260 _Scheduler_simple_SMP_Enqueue_ fifo( context, thread, true);305 _Scheduler_simple_SMP_Enqueue_scheduled_fifo( context, thread ); 261 306 262 307 _ISR_Enable( level ); -
testsuites/smptests/Makefile.am
rb4bdbcf rc0bff5e 26 26 SUBDIRS += smpscheduler01 27 27 SUBDIRS += smpscheduler02 28 SUBDIRS += smpscheduler03 28 29 SUBDIRS += smpsignal01 29 30 SUBDIRS += smpswitchextension01 -
testsuites/smptests/configure.ac
rb4bdbcf rc0bff5e 84 84 smpscheduler01/Makefile 85 85 smpscheduler02/Makefile 86 smpscheduler03/Makefile 86 87 smpsignal01/Makefile 87 88 smpswitchextension01/Makefile
Note: See TracChangeset
for help on using the changeset viewer.