Changeset 440 for trunk/user/init/init.c
- Timestamp:
- May 3, 2018, 5:51:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/init/init.c
r438 r440 7 7 // It uses the fork/exec syscalls to create N KSH child processes 8 8 // (one child process per user terminal). 9 // It includes the hard_config.h file to get th NB_TXT_CHANNELS parameter.10 //11 // TODO : Register the PIDs for all KSH[i] in a ksh_pid[] array.12 9 // Then calls the wait() function to block, and reactivate any child KSH process 13 10 // that has been deleted, using a new fork/exec. 11 // It includes the hard_config.h file to get th NB_TXT_CHANNELS parameter. 14 12 /////////////////////////////////////////////////////////////////////////////////////// 15 13 … … 19 17 #include <stdio.h> 20 18 #include <pthread.h> 19 20 #define DEBUG_INIT 1 21 22 // TODO make the cxy computation portable [AG] 23 #define CXY_FROM_XY( x , y ) ((x<<4) + y) 21 24 22 25 ////////// … … 43 46 { 44 47 // INIT display error message 45 snprintf( string , 64 , " INITcannot fork child[%d] => suicide" , i );48 snprintf( string , 64 , "[INIT] cannot fork child[%d] => suicide" , i ); 46 49 display_string( string ); 47 50 … … 58 61 // CHILD[i] display error message 59 62 snprintf( string , 64 , 60 " CHILD[%d] cannot exec KSH[%d] / ret_exec = %d" , i, i , ret_exec );63 "[INIT ERROR] CHILD[%d] cannot exec KSH / ret_exec = %d" , i , ret_exec ); 61 64 display_string( string ); 62 65 } … … 65 68 { 66 69 // INIT display CHILD[i] process PID 67 snprintf( string , 64 , " INITcreated KSH[%d] / pid = %x", i , ret_fork );70 snprintf( string , 64 , "[INIT] created KSH[%d] / pid = %x", i , ret_fork ); 68 71 display_string( string ); 69 72 … … 72 75 } 73 76 } 77 78 #if DEBUG_INIT 74 79 75 // INIT display processes and threads in clusters 0 & 1 76 display_cluster_processes( 0 ); 77 display_sched( 0 , 0 ); 78 display_cluster_processes( 1 ); 79 display_sched( 1 , 0 ); 80 unsigned int x_size; // number of clusters in a row 81 unsigned int y_size; // number of clusters in a column 82 unsigned int ncores; // number of cores per cluster 83 unsigned int x; // cluster x coordinate 84 unsigned int y; // cluster y coordinate 85 unsigned int cxy; // cluster identifier 86 unsigned int lid; // core local index 87 88 // get hardware config 89 get_config( &x_size , &y_size , &ncores ); 90 91 // INIT displays processes and threads in all clusters 92 for( x = 0 ; x < x_size ; x++ ) 93 { 94 for( y = 0 ; y < y_size ; y++ ) 95 { 96 cxy = CXY_FROM_XY( x , y ); 97 display_cluster_processes( cxy ); 98 for( lid = 0 ; lid < ncores ; lid++ ) 99 { 100 display_sched( cxy , lid ); 101 } 102 } 103 } 104 105 #endif 80 106 81 107 // This loop detects the termination of the KSH[i] processes, … … 89 115 { 90 116 // display string to report unexpected KSH process block 91 snprintf( string , 64 , " KSH process %x stopped => unblock it" , rcv_pid );117 snprintf( string , 64 , "[INIT] KSH process %x stopped => unblock it" , rcv_pid ); 92 118 display_string( string ); 93 119 94 // TODO : unblock KSH 120 // TODO : unblock KSH [AG] 95 121 96 122 } // end KSH stopped handling … … 99 125 { 100 126 // display string to report KSH process termination 101 snprintf( string , 64 , " KSH process %x terminated => recreate KSH", rcv_pid );127 snprintf( string , 64 , "[INIT] KSH process %x terminated => recreate", rcv_pid ); 102 128 display_string( string ); 103 129 … … 108 134 { 109 135 // INIT display error message 110 snprintf( string , 64 , " INITcannot fork child => suicide");136 snprintf( string , 64 , "[INIT ERROR] cannot fork child => suicide"); 111 137 display_string( string ); 112 138 … … 122 148 { 123 149 // CHILD display error message on TXT0 terminal 124 snprintf( string , 64 , " CHILD cannot exec KSH" );150 snprintf( string , 64 , "[INIT ERROR] CHILD cannot exec KSH" ); 125 151 display_string( string ); 126 152 } … … 129 155 { 130 156 // INIT display new CHILD process PID 131 snprintf( string , 64 , " INITforked CHILD / pid = %x", ret_fork );157 snprintf( string , 64 , "[INIT] forked CHILD / pid = %x", ret_fork ); 132 158 display_string( string ); 133 159 } 134 160 } // end KSH kill handling 135 161 136 // INIT wait a fixed delay 137 for( delay = 0 ; delay < 50000 ; delay++ ) asm volatile( "nop" ); 162 #if( DEBUG_INIT ) 138 163 139 // INIT display processes and threads in clusters 0 & 1 140 display_cluster_processes( 0 ); 141 display_sched( 0 , 0 ); 142 display_cluster_processes( 1 ); 143 display_sched( 1 , 0 ); 164 // INIT displays processes and threads in all clusters 165 for( x = 0 ; x < x_size ; x++ ) 166 { 167 for( y = 0 ; y < y_size ; y++ ) 168 { 169 cxy = CXY_FROM_XY( x , y ); 170 display_cluster_processes( cxy ); 171 for( lid = 0 ; lid < ncores ; lid++ ) 172 { 173 display_sched( cxy , lid ); 174 } 175 } 176 } 177 178 #endif 144 179 145 180 } // end while waiting KSH[i] termination
Note: See TracChangeset
for help on using the changeset viewer.