Changeset 443 for trunk/kernel/kern/cluster.c
- Timestamp:
- May 16, 2018, 4:15:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/cluster.c
r440 r443 34 34 #include <spinlock.h> 35 35 #include <core.h> 36 #include <chdev.h> 36 37 #include <scheduler.h> 37 38 #include <list.h> … … 49 50 ///////////////////////////////////////////////////////////////////////////////////// 50 51 51 extern process_t process_zero; // allocated in kernel_init.c file52 53 54 /////////////////////////////////////////////// //52 extern process_t process_zero; // allocated in kernel_init.c file 53 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c file 54 55 ///////////////////////////////////////////////n 55 56 error_t cluster_init( struct boot_info_s * info ) 56 57 { … … 252 253 253 254 ////////////////////////////////////////////////////// 255 xptr_t cluster_get_process_from_pid_in_cxy( cxy_t cxy, 256 pid_t pid ) 257 { 258 xptr_t root_xp; // xptr on root of list of processes in owner cluster 259 xptr_t lock_xp; // xptr on lock protecting this list 260 xptr_t iter_xp; // iterator 261 xptr_t current_xp; // xptr on current process descriptor 262 bool_t found; 263 264 cluster_t * cluster = LOCAL_CLUSTER; 265 266 // get owner cluster and lpid 267 cxy_t owner_cxy = CXY_FROM_PID( pid ); 268 lpid_t lpid = LPID_FROM_PID( pid ); 269 270 // get lock & root of list of copies from owner cluster 271 root_xp = XPTR( owner_cxy , &cluster->pmgr.copies_root[lpid] ); 272 lock_xp = XPTR( owner_cxy , &cluster->pmgr.copies_lock[lpid] ); 273 274 // take the lock protecting the list of processes 275 remote_spinlock_lock( lock_xp ); 276 277 // scan list of processes 278 found = false; 279 XLIST_FOREACH( root_xp , iter_xp ) 280 { 281 current_xp = XLIST_ELEMENT( iter_xp , process_t , copies_list ); 282 283 if( GET_CXY( current_xp ) == cxy ) 284 { 285 found = true; 286 break; 287 } 288 } 289 290 // release the lock protecting the list of processes 291 remote_spinlock_unlock( lock_xp ); 292 293 // return extended pointer on process descriptor in owner cluster 294 if( found ) return current_xp; 295 else return XPTR_NULL; 296 297 } // end cluster_get_process_from_pid_in_cxy() 298 299 300 ////////////////////////////////////////////////////// 254 301 xptr_t cluster_get_owner_process_from_pid( pid_t pid ) 255 302 { … … 298 345 } // end cluster_get_owner_process_from_pid() 299 346 347 300 348 ////////////////////////////////////////////////////////// 301 349 xptr_t cluster_get_reference_process_from_pid( pid_t pid ) … … 459 507 void cluster_process_local_link( process_t * process ) 460 508 { 461 uint32_t irq_state; 509 reg_t save_sr; 510 462 511 pmgr_t * pm = &LOCAL_CLUSTER->pmgr; 463 512 513 // get extended pointers on local process list root & lock 514 xptr_t root_xp = XPTR( local_cxy , &pm->local_root ); 515 xptr_t lock_xp = XPTR( local_cxy , &pm->local_lock ); 516 464 517 // get lock protecting the process manager local list 465 remote_spinlock_lock_busy( XPTR( local_cxy , &pm->local_lock ) , & irq_state);466 467 xlist_add_last( XPTR( local_cxy , &pm->local_root ),468 518 remote_spinlock_lock_busy( lock_xp , &save_sr ); 519 520 // register process in local list 521 xlist_add_last( root_xp , XPTR( local_cxy , &process->local_list ) ); 469 522 pm->local_nr++; 470 523 471 524 // release lock protecting the process manager local list 472 remote_spinlock_unlock_busy( XPTR( local_cxy , &pm->local_lock ) , irq_state);525 remote_spinlock_unlock_busy( lock_xp , save_sr ); 473 526 } 474 527 … … 476 529 void cluster_process_local_unlink( process_t * process ) 477 530 { 478 uint32_t irq_state; 531 reg_t save_sr; 532 479 533 pmgr_t * pm = &LOCAL_CLUSTER->pmgr; 480 534 535 // get extended pointers on local process list lock 536 xptr_t lock_xp = XPTR( local_cxy , &pm->local_lock ); 537 481 538 // get lock protecting the process manager local list 482 remote_spinlock_lock_busy( XPTR( local_cxy , &pm->local_lock ) , &irq_state ); 483 539 remote_spinlock_lock_busy( lock_xp , &save_sr ); 540 541 // remove process from local list 484 542 xlist_unlink( XPTR( local_cxy , &process->local_list ) ); 485 543 pm->local_nr--; 486 544 487 545 // release lock protecting the process manager local list 488 remote_spinlock_unlock_busy( XPTR( local_cxy , &pm->local_lock ) , irq_state);546 remote_spinlock_unlock_busy( lock_xp , save_sr ); 489 547 } 490 548 … … 582 640 { 583 641 xptr_t root_xp; 642 xptr_t lock_xp; 584 643 xptr_t iter_xp; 585 xptr_t process_xp; 586 587 // get extended pointer on root of process in cluster cxy 644 xptr_t process_xp; 645 cxy_t txt0_cxy; 646 chdev_t * txt0_ptr; 647 xptr_t txt0_xp; 648 xptr_t txt0_lock_xp; 649 reg_t txt0_save_sr; // save SR to take TXT0 lock in busy mode 650 651 assert( (cluster_is_undefined( cxy ) == false), 652 __FUNCTION__, "illegal cluster index" ); 653 654 // get extended pointer on root and lock for local process list in cluster 588 655 root_xp = XPTR( cxy , &LOCAL_CLUSTER->pmgr.local_root ); 589 590 // skip one line 591 printk("\n***** processes in cluster %x / cycle %d\n", cxy , (uint32_t)hal_get_cycles() ); 592 593 // loop on all reference processes in cluster cxy 656 lock_xp = XPTR( cxy , &LOCAL_CLUSTER->pmgr.local_lock ); 657 658 // get pointers on TXT0 chdev 659 txt0_xp = chdev_dir.txt_tx[0]; 660 txt0_cxy = GET_CXY( txt0_xp ); 661 txt0_ptr = GET_PTR( txt0_xp ); 662 663 // get extended pointer on TXT0 lock 664 txt0_lock_xp = XPTR( txt0_cxy , &txt0_ptr->wait_lock ); 665 666 // get lock on local process list 667 remote_spinlock_lock( lock_xp ); 668 669 // get TXT0 lock in busy waiting mode 670 remote_spinlock_lock_busy( txt0_lock_xp , &txt0_save_sr ); 671 672 // display header 673 nolock_printk("\n***** processes in cluster %x / cycle %d\n", 674 cxy , (uint32_t)hal_get_cycles() ); 675 676 // loop on all processes in cluster cxy 594 677 XLIST_FOREACH( root_xp , iter_xp ) 595 678 { … … 597 680 process_display( process_xp ); 598 681 } 682 683 // release TXT0 lock in busy waiting mode 684 remote_spinlock_unlock_busy( txt0_lock_xp , txt0_save_sr ); 685 686 // release lock on local process list 687 remote_spinlock_unlock( lock_xp ); 688 599 689 } // end cluster_processes_display() 600 690
Note: See TracChangeset
for help on using the changeset viewer.