Changeset 204 for trunk/kernel/kern/process.c
- Timestamp:
- Jul 17, 2017, 8:42:59 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/kern/process.c
r188 r204 112 112 } 113 113 114 // initialize PID and PPID 115 process->pid = pid; 116 process->ppid = parent_pid; 117 114 118 // reset reference process vmm (not for kernel process) 115 119 if( pid ) vmm_init( process ); … … 152 156 spinlock_init( &process->th_lock ); 153 157 154 // initialize PID and PPID155 process->pid = pid;156 process->ppid = parent_pid;157 158 158 // set ref_xp field 159 159 process->ref_xp = XPTR( local_cxy , process ); … … 171 171 process_dmsg("\n[INFO] %s : exit for process %x in cluster %x\n", 172 172 __FUNCTION__ , pid ); 173 } 173 174 } // process_reference init() 174 175 175 176 ///////////////////////////////////////////////////// … … 230 231 231 232 return 0; 232 } 233 234 } // end process_copy_init() 233 235 234 236 /////////////////////////////////////////// … … 578 580 579 581 return (found) ? 0 : ENOMEM; 580 } 582 583 } // end process_register_thread() 584 581 585 /////////////////////////////////////////////// 582 586 void process_remove_thread( thread_t * thread ) … … 596 600 process->th_tbl[ltid] = NULL; 597 601 process->th_nr--; 598 } 602 603 } // process_remove_thread() 599 604 600 605 ///////////////////////////////////////////////////// … … 623 628 parent_pid = hal_remote_lw( XPTR( parent_cxy , &parent_ptr->pid ) ); 624 629 625 exec_dmsg("\n[INFO] %s enters in cluster %x for path = %s\n",630 exec_dmsg("\n[INFO] %s : enters in cluster %x for path = %s\n", 626 631 __FUNCTION__ , local_cxy , path ); 627 632 … … 650 655 process_reference_init( process , pid , parent_xp ); 651 656 652 exec_dmsg("\n[INFO] %s created process %xcluster %x / path = %s\n",653 __FUNCTION__, p arent_pid , local_cxy , path );657 exec_dmsg("\n[INFO] %s : created process %x in cluster %x / path = %s\n", 658 __FUNCTION__, pid , local_cxy , path ); 654 659 655 660 // initialize vfs_root and vfs_cwd from parent process … … 663 668 664 669 // initialize embedded fd_array from parent process 665 process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ),670 process_fd_remote_copy( XPTR( local_cxy , &process->fd_array ), 666 671 XPTR( parent_cxy , &parent_ptr->fd_array) ); 672 673 exec_dmsg("\n[INFO] %s : fd_array copied from process %x to process %x\n", 674 __FUNCTION__, parent_pid , pid ); 667 675 668 676 // initialize signal manager TODO ??? [AG] 669 677 // signal_manager_init( process ); 670 671 // initialize process VMM672 vmm_init( process );673 674 exec_dmsg("\n[INFO] %s initialized VMM in cluster %x for process %x / path = %s\n",675 __FUNCTION__ , local_cxy , pid , path );676 678 677 679 // register "code" and "data" vsegs as well as the process entry-point in VMM, … … 687 689 } 688 690 689 // register "heap" vseg descriptor in VMM 690 vseg_t * heap_vseg = vmm_create_vseg( process, 691 CONFIG_VMM_HEAP_BASE, 692 CONFIG_VMM_HEAP_SIZE, 693 VSEG_TYPE_HEAP ); 694 if( heap_vseg == NULL ) 695 { 696 printk("\n[ERROR] in %s : cannot create heap vseg for process %x / path = %s\n", 697 __FUNCTION__, pid , path ); 698 process_destroy( process ); 699 return error; 700 } 691 exec_dmsg("\n[INFO] %s : code and data vsegs from <%s> registered for process %x\n", 692 __FUNCTION__ , path , pid ); 701 693 702 694 // select a core in cluster … … 718 710 { 719 711 printk("\n[ERROR] in %s : cannot create thread for process %x / path = %s\n", 720 __FUNCTION__, pid , path);712 __FUNCTION__, pid ); 721 713 process_destroy( process ); 722 714 return error; 723 715 } 716 717 exec_dmsg("\n[INFO] %s : thread created for process %x on core %d in cluster %x\n", 718 __FUNCTION__ , pid , core->lid , local_cxy ); 724 719 725 720 // update children list in parent process … … 731 726 sched_register_thread( core , thread ); 732 727 733 exec_dmsg("\n[INFO] %s created thread for process %x on core %d in cluster %x\n",734 __FUNCTION__ , pid , core->lid , local_cxy );735 736 728 // activate new thread 737 729 thread_unblock( XPTR( local_cxy , thread ) , THREAD_BLOCKED_GLOBAL ); 738 730 731 exec_dmsg("\n[INFO] %s : exit for process %x\n", 732 __FUNCTION__, process->pid ); 733 739 734 return 0; 740 } 735 736 } // end proces_make_exec() 741 737 742 738 ////////////////////////// … … 755 751 uint32_t stderr_id; 756 752 757 process_dmsg("\n[INFO] %s enters in cluster %x\n", __FUNCTION__ , local_cxy );753 process_dmsg("\n[INFO] %s : enters in cluster %x\n", __FUNCTION__ , local_cxy ); 758 754 759 755 // open stdin / stdout / stderr pseudo-files … … 762 758 error3 = vfs_open( XPTR_NULL, CONFIG_DEV_STDERR, O_WRONLY, 0, &stderr_xp, &stderr_id ); 763 759 764 if( error1 || error2 || error3 ) 765 { 766 if( !error1 ) vfs_close( stdin_xp , stdin_id ); 767 if( !error2 ) vfs_close( stdout_xp , stdout_id ); 768 if( !error3 ) vfs_close( stderr_xp , stderr_id ); 769 printk("\n[PANIC] in %s : cannot open stdin/stdout/stderr in cluster %x\n", 770 __FUNCTION__ , local_cxy ); 771 hal_core_sleep(); 772 } 773 774 // check stdin / stdout / stderr indexes 775 if( (stdin_id != 0) || (stdout_id != 1) || (stderr_id != 2) ) 776 { 777 vfs_close( stdin_xp , stdin_id ); 778 vfs_close( stdout_xp , stdout_id ); 779 vfs_close( stderr_xp , stderr_id ); 780 printk("\n[PANIC] in %s : bad indexes for stdin/stdout/stderr in cluster %x\n", 781 __FUNCTION__ , local_cxy ); 782 hal_core_sleep(); 783 } 760 assert( ((error1 == 0) && (error2 == 0) && (error3 == 0)) , __FUNCTION__ , 761 "cannot open stdin/stdout/stderr pseudo files\n"); 762 763 assert( ((stdin_id == 0) && (stdout_id == 1) && (stderr_id == 2)) , __FUNCTION__ , 764 "bad indexes for stdin/stdout/stderr\n"); 784 765 785 766 // initialize the exec_info structure … … 792 773 error1 = process_make_exec( &exec_info ); 793 774 794 if( error1 ) 795 { 796 printk("\n[PANIC] in %s : cannot create main thread in cluster %x\n", 797 __FUNCTION__ , local_cxy ); 798 hal_core_sleep(); 799 } 800 801 process_dmsg("\n[INFO] %s successfully exit in cluster %x\n", __FUNCTION__ , local_cxy ); 775 assert( (error1 == 0) , __FUNCTION__ , "cannot create process_init\n"); 776 777 process_dmsg("\n[INFO] %s : exit in cluster %x\n", __FUNCTION__ , local_cxy ); 802 778 803 779 hal_fence(); 804 } 805 780 781 } // end process_init_create() 782
Note: See TracChangeset
for help on using the changeset viewer.