Changeset 435 for trunk/user/init/init.c
- Timestamp:
- Feb 20, 2018, 5:32:17 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/init/init.c
r434 r435 38 38 for( i = 1 ; i < NB_TXT_CHANNELS ; i++ ) 39 39 { 40 41 snprintf( string , 64 , "@@@ before fork / iter = %d\n" , i );42 display_string( string );43 44 40 // INIT process fork process CHILD[i] 45 41 ret_fork = fork(); 46 47 snprintf( string , 64 , "@@@ after fork / iter = %d / ret_fork = %d\n" , i , ret_fork );48 display_string( string );49 42 50 43 if( ret_fork< 0 ) // error in fork 51 44 { 52 45 // INIT display error message on TXT0 terminal 53 snprintf( string , 64 , "init cannot fork child[%d]\n" , i ); 46 snprintf( string , 64 , 47 "INIT cannot fork child[%d]\n" , i ); 54 48 display_string( string ); 55 49 … … 65 59 { 66 60 // display error message on TXT0 terminal 67 snprintf( string , 64 , "child[%d] cannot exec ksh[%d]\n" , i , i ); 61 snprintf( string , 64 , 62 "CHILD[%d] cannot exec KSH[%d] / ret_exec = %d\n" , i , i , ret_exec ); 68 63 display_string( string ); 69 70 // CHILD[i] exit71 // exit( 0 );72 64 } 73 65 } … … 75 67 { 76 68 // INIT display CHILD[i] process PID 77 snprintf( string , 64 , "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork ); 69 snprintf( string , 64 , 70 "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork ); 78 71 display_string( string ); 79 80 // INIT delay81 int x;82 for( x=0 ; x<DELAY_BETWEEN_FORK ; x++) asm volatile ("nop");83 84 /*85 // INIT wait exec completion by CHILD[i]86 while( 1 )87 {88 // get terminating process PID89 received_pid = wait( &status );90 91 if( received_pid == ret_fork ) break;92 else93 {94 snprintf( string , 64 ,95 "expected_pid %d / received_pid %d" , ret_fork , received_pid );96 display_string( string );97 }98 }99 100 */101 // INIT display string on kernel TXT0102 snprintf( string , 64 , "INIT created KSH[%d]\n", i );103 display_string( string );104 // @@@105 display_process( 0 );106 display_sched( 0 , 0 );107 // @@@108 72 } 109 73 110 74 } 111 75 112 // This blocking loop is only for debug, because KSH[i] processes113 // should never be killed, and INIT should never return from the wait() function.76 // This loop detects the termination of the KSH[i] processes, 77 // to recreate these process when required. 114 78 while( 1 ) 115 79 { 116 // block on child process termination117 received_pid = wait( &status ); 80 // block on child processes termination 81 received_pid = wait( &status ); 118 82 119 // display string to report unexpected KSH process termination 120 snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid ); 121 display_string( string ); 83 if( WIFSTOPPED( status ) ) // stopped => unblock it 84 { 85 // display string to report unexpected KSH process block 86 snprintf( string , 64 , "KSH process %x unexpectedly stopped" , received_pid ); 87 display_string( string ); 88 89 } 90 91 if( WIFSIGNALED( status ) || WIFEXITED( status ) ) // killed => recreate it 92 { 93 // display string to report unexpected KSH process termination 94 snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid ); 95 display_string( string ); 96 } 122 97 } 123 98
Note: See TracChangeset
for help on using the changeset viewer.