Changeset 416 for trunk/kernel/kern/thread.c
- Timestamp:
- Jan 4, 2018, 10:05:47 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/thread.c
r409 r416 696 696 } // thread_child_parent_unlink() 697 697 698 ///////////////////////////////////////////////// 699 inline void thread_set_ signal( thread_t * thread,700 uint32_t * sig_rsp_count )698 ////////////////////////////////////////////////// 699 inline void thread_set_req_ack( thread_t * target, 700 uint32_t * rsp_count ) 701 701 { 702 702 reg_t save_sr; // for critical section 703 703 704 // get pointer on t hreadthread scheduler705 scheduler_t * thread_sched = &thread->core->scheduler;706 707 // wait scheduler ready to handle a new signal708 while( thread_sched->sig_pending ) asm volatile( "nop" );704 // get pointer on target thread scheduler 705 scheduler_t * sched = &target->core->scheduler; 706 707 // wait scheduler ready to handle a new request 708 while( sched->req_ack_pending ) asm volatile( "nop" ); 709 709 710 710 // enter critical section 711 711 hal_disable_irq( &save_sr ); 712 712 713 // set signal inthread scheduler714 thread_sched->sig_pending = true;715 716 // set signal in threadthread "flags"717 hal_atomic_or( &t hread->flags , THREAD_FLAG_SIGNAL);718 719 // set pointer on responses counter in t hreadthread720 t hread->sig_rsp_count = sig_rsp_count;713 // set request in target thread scheduler 714 sched->req_ack_pending = true; 715 716 // set ack request in target thread "flags" 717 hal_atomic_or( &target->flags , THREAD_FLAG_REQ_ACK ); 718 719 // set pointer on responses counter in target thread 720 target->ack_rsp_count = rsp_count; 721 721 722 722 // exit critical section … … 725 725 hal_fence(); 726 726 727 } // thread_set_ signal()728 729 //////////////////////////////////////////////////// 730 inline void thread_reset_ signal( thread_t * thread)727 } // thread_set_req_ack() 728 729 ///////////////////////////////////////////////////// 730 inline void thread_reset_req_ack( thread_t * target ) 731 731 { 732 732 reg_t save_sr; // for critical section 733 733 734 734 // get pointer on target thread scheduler 735 scheduler_t * sched = &t hread->core->scheduler;735 scheduler_t * sched = &target->core->scheduler; 736 736 737 737 // check signal pending in scheduler 738 assert( sched-> sig_pending , __FUNCTION__ , "no pending signal" );738 assert( sched->req_ack_pending , __FUNCTION__ , "no pending signal" ); 739 739 740 740 // enter critical section … … 742 742 743 743 // reset signal in scheduler 744 sched-> sig_pending = false;744 sched->req_ack_pending = false; 745 745 746 746 // reset signal in thread "flags" 747 hal_atomic_and( &t hread->flags , ~THREAD_FLAG_SIGNAL);747 hal_atomic_and( &target->flags , ~THREAD_FLAG_REQ_ACK ); 748 748 749 749 // reset pointer on responses counter 750 t hread->sig_rsp_count = NULL;750 target->ack_rsp_count = NULL; 751 751 752 752 // exit critical section … … 755 755 hal_fence(); 756 756 757 } // thread_reset_ signal()757 } // thread_reset_req_ack() 758 758 759 759 //////////////////////////////// … … 809 809 void thread_kill( thread_t * target ) 810 810 { 811 volatile uint32_t sig_rsp_count = 1; // responses counter811 volatile uint32_t rsp_count = 1; // responses counter 812 812 813 813 thread_t * killer = CURRENT_THREAD; 814 814 815 kill_dmsg("\n[DBG] %s : killer thread %x enter for target thread %x\n",815 thread_dmsg("\n[DBG] %s : killer thread %x enter for target thread %x\n", 816 816 __FUNCTION__, local_cxy, killer->trdid , target trdid ); 817 817 … … 824 824 { 825 825 // set signal in target thread descriptor and in target scheduler 826 thread_set_ signal( target , (uint32_t *)(&sig_rsp_count) );826 thread_set_req_ack( target , (void *)(&rsp_count) ); 827 827 828 828 // send an IPI to the target thread core. … … 833 833 { 834 834 // exit when response received from scheduler 835 if( sig_rsp_count == 0 ) break;835 if( rsp_count == 0 ) break; 836 836 837 837 // deschedule without blocking … … 840 840 } 841 841 842 // release FPU if required 843 if( target->core->fpu_owner == target ) target->core->fpu_owner = NULL; 844 845 // detach thread from parent if attached 846 if( (target->flags & THREAD_FLAG_DETACHED) == 0 ) 847 thread_child_parent_unlink( target->parent , XPTR( local_cxy , target ) ); 848 849 // detach thread from process 850 process_remove_thread( target ); 851 852 // remove thread from scheduler 853 sched_remove_thread( target ); 854 855 // release memory allocated to target thread 856 thread_destroy( target ); 857 858 kill_dmsg("\n[DBG] %s : killer thread %x enter for target thread %x\n", 842 // set REQ_DELETE flag 843 hal_atomic_or( &target->flags , THREAD_FLAG_REQ_DELETE ); 844 845 thread_dmsg("\n[DBG] %s : killer thread %x exit for target thread %x\n", 859 846 __FUNCTION__, local_cxy, killer->trdid , target trdid ); 860 847
Note: See TracChangeset
for help on using the changeset viewer.