Changeset 682 for trunk/user/init
- Timestamp:
- Jan 3, 2021, 11:32:52 PM (4 years ago)
- Location:
- trunk/user/init
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/init/init.c
r676 r682 7 7 // It uses the fork/exec syscalls to create N KSH child processes 8 8 // (one child process per user TXT terminal). 9 // Then calls the wait() function to block, and recreate any child KSH process9 // Then it calls the wait() function to block, and recreate any child KSH process 10 10 // that has been deleted, using a new fork/exec. 11 11 /////////////////////////////////////////////////////////////////////////////////////// … … 31 31 int status; // used by the wait syscall 32 32 char string[64]; // log messages on kernel TXT0 33 unsigned int cxy; // target cluster identifier 33 34 34 35 #if DEBUG_PROCESS_INIT … … 36 37 #endif 37 38 38 // get number of TXT channels from hard configuration39 // get number of TXT channels and number of clusters 39 40 hard_config_t config; 40 41 … … 42 43 43 44 unsigned int txt_channels = config.txt_channels; 45 unsigned int x_size = config.x_size; 46 unsigned int y_size = config.y_size; 47 unsigned int n_clusters = x_size * y_size; 44 48 45 49 // check number of TXT channels … … 52 56 } 53 57 58 cxy = 0; 59 54 60 // create the KSH processes (one per user terminal) 55 61 for( i = 1 ; i < txt_channels ; i++ ) 56 62 { 63 // compute target cluster 64 cxy = (cxy + 1) % n_clusters; 65 66 // select target cluster 67 if( place_fork( cxy ) ) 68 { 69 // INIT display error message 70 snprintf( string , 64 , 71 "\n[init ERROR] cannot place fork for child[%d] => suicide" , i ); 72 display_string( string ); 73 74 // INIT suicide 75 exit( EXIT_FAILURE ); 76 } 77 78 57 79 // INIT process fork process CHILD[i] 58 80 ret_fork = fork(); … … 94 116 // INIT display CHILD[i] process PID 95 117 snprintf( string , 64 , 96 "\n[init] (pid 0x1) create ksh[%d] (pid %x)", i , ret_fork ); 97 display_string( string ); 98 99 // wait signal from KSH[i] before creating KSH[i+1] 100 pause(); 118 "[init] (pid 0x1) create ksh[%d] (pid %x)", i , ret_fork ); 119 display_string( string ); 101 120 } 102 121 } … … 104 123 #if DEBUG_PROCESS_INIT 105 124 { 125 // keep blocked for 2 seconds 126 // to allow all KSH[i] process 127 // to be launched before display 128 129 sleep( 2 ); 130 106 131 unsigned int x; // cluster x coordinate 107 132 unsigned int y; // cluster y coordinate
Note: See TracChangeset
for help on using the changeset viewer.