Changeset 659 for trunk/user
- Timestamp:
- Oct 10, 2020, 3:58:01 PM (4 years ago)
- Location:
- trunk/user
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/convol/convol.c
r656 r659 187 187 188 188 // get & check platform parameters 189 get_config( &x_size , &y_size , &ncores ); 189 hard_config_t config; 190 get_config( &config ); 191 x_size = config.x_size; 192 y_size = config.y_size; 193 ncores = config.ncores; 190 194 191 195 if((ncores != 1) && (ncores != 2) && (ncores != 4)) -
trunk/user/fft/fft.c
r656 r659 290 290 291 291 // get platform parameters 292 if( get_config( &x_size , &y_size , &ncores ) ) 292 hard_config_t config; 293 if( get_config( &config ) ) 293 294 { 294 295 printf("\n[fft error] cannot get hardware configuration\n"); 295 296 exit( 0 ); 296 297 } 298 299 x_size = config.x_size; 300 y_size = config.y_size; 301 ncores = config.ncores; 297 302 298 303 // check ncores -
trunk/user/init/init.c
r635 r659 6 6 // This single thread application implement the "init" process for ALMOS-MKH. 7 7 // It uses the fork/exec syscalls to create N KSH child processes 8 // (one child process per user terminal).9 // Then calls the wait() function to block, and re activate any child KSH process8 // (one child process per user TXT terminal). 9 // Then calls the wait() function to block, and recreate any child KSH process 10 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.12 11 /////////////////////////////////////////////////////////////////////////////////////// 13 12 14 #include <hard_config.h>15 13 #include <unistd.h> 16 14 #include <stdlib.h> … … 20 18 #include <hal_macros.h> 21 19 #include <sys/wait.h> 20 #include <shared_syscalls.h> 22 21 23 #define DEBUG_PROCESS_INIT 0 24 25 // TODO improve the get_config() syscall to return nb_txt_channels 26 // and avoid the hard_config include [AG] 22 #define DEBUG_PROCESS_INIT 1 27 23 28 24 //////////////// 29 25 int main( void ) 30 26 { 31 inti;27 unsigned int i; 32 28 int ret_fork; // fork return value 33 29 int ret_exec; // exec return value … … 40 36 #endif 41 37 38 // get Number of TXT channels from hard configuration 39 hard_config_t config; 40 get_config( &config ); 41 42 unsigned int txt_channels = config.txt_channels; 43 unsigned int x_size = config.x_size; 44 unsigned int y_size = config.y_size; 45 unsigned int ncores = config.ncores; 46 42 47 // check number of TXT channels 43 if( NB_TXT_CHANNELS< 2 )48 if( txt_channels < 2 ) 44 49 { 45 printf("\n[ERROR] in init process : number of TXT channels must be larger than 1\n"); 50 snprintf( string , 64 , 51 "\n[init ERROR] number of TXT channels must be larger than 1\n"); 52 display_string( string ); 46 53 exit( EXIT_FAILURE ); 47 54 } 48 55 49 56 // create the KSH processes (one per user terminal) 50 for( i = 1 ; i < NB_TXT_CHANNELS; i++ )57 for( i = 1 ; i < txt_channels ; i++ ) 51 58 { 52 59 // INIT process fork process CHILD[i] … … 56 63 { 57 64 // INIT display error message 58 snprintf( string , 64 , "[init ERROR] cannot fork child[%d] => suicide" , i ); 65 snprintf( string , 64 , 66 "[init ERROR] cannot fork child[%d] => suicide" , i ); 59 67 display_string( string ); 60 68 61 69 // INIT suicide 62 exit( 0);70 exit( EXIT_FAILURE ); 63 71 } 64 72 else if( ret_fork == 0 ) // we are in CHILD[i] process … … 73 81 "[init ERROR] CHILD[%d] cannot exec KSH / ret_exec = %d" , i , ret_exec ); 74 82 display_string( string ); 83 84 // CHILD[i] suicide 85 exit( EXIT_FAILURE ); 75 86 } 76 87 } … … 78 89 { 79 90 // INIT display CHILD[i] process PID 80 snprintf( string , 64 , "[init] (pid 0x1) created ksh[%d] (pid %x)", i , ret_fork ); 91 snprintf( string , 64 , 92 "[init] (pid 0x1) created ksh[%d] (pid %x)", i , ret_fork ); 81 93 display_string( string ); 82 94 83 // wait signal from KSH[i] 95 // wait signal from KSH[i] before creating KSH[i+1] 84 96 pause(); 85 97 } … … 88 100 #if DEBUG_PROCESS_INIT 89 101 { 90 unsigned int x_size; // number of clusters in a row91 unsigned int y_size; // number of clusters in a column92 unsigned int ncores; // number of cores per cluster93 102 unsigned int x; // cluster x coordinate 94 103 unsigned int y; // cluster y coordinate 95 104 unsigned int cxy; // cluster identifier 96 105 unsigned int lid; // core local index 97 98 // get hardware config99 get_config( &x_size , &y_size , &ncores );100 106 101 107 // INIT displays processes and threads in all clusters -
trunk/user/ksh/ksh.c
r657 r659 50 50 #include <sys/mman.h> 51 51 #include <fcntl.h> 52 53 #define CMD_MAX_SIZE (256) // max number of characters in one command 54 #define LOG_DEPTH (32) // max number of registered commands 55 #define MAX_ARGS (32) // max number of arguments in a command 56 #define PATH_MAX_SIZE (256) // max number of characters in a pathname 52 #include <shared_syscalls.h> 53 54 #define CMD_MAX_SIZE (256) // max number of characters in one command 55 #define LOG_DEPTH (32) // max number of registered commands 56 #define MAX_ARGS (32) // max number of arguments in a command 57 #define PATH_MAX_SIZE (256) // max number of characters in a pathname 57 58 58 59 #define DEBUG_MAIN 0 … … 414 415 " display mapper path page nbytes\n" 415 416 " display fat min nslots\n" 416 " display fat cxy 0\n" ); 417 " display fat cxy 0\n" 418 " display socket pid fdid\n" ); 417 419 } 418 420 //////////////////////////////////// … … 594 596 } 595 597 } 598 /////////////////////////////////////////// 599 else if( strcmp( argv[1] , "socket" ) == 0 ) 600 { 601 if( argc != 4 ) 602 { 603 printf(" usage: display socket pid fdid\n"); 604 } 605 else 606 { 607 unsigned int pid = atoi(argv[2]); 608 unsigned int fdid = atoi(argv[3]); 609 610 if( display_socket( pid , fdid ) ) 611 { 612 printf(" error: cannot found socket[%x,%d]\n", pid, fdid ); 613 } 614 } 615 } 616 //// 596 617 else 597 618 { … … 939 960 unsigned int x_size; 940 961 unsigned int y_size; 941 unsigned int ncores;942 962 unsigned int x; 943 963 unsigned int y; … … 955 975 { 956 976 // get platform config 957 get_config( &x_size , &y_size , &ncores ); 977 hard_config_t config; 978 get_config( &config ); 979 x_size = config.x_size; 980 y_size = config.y_size; 958 981 959 982 // scan all clusters … … 1224 1247 char cmd[CMD_MAX_SIZE]; // buffer for one command 1225 1248 1226 1227 1228 // 1. first direct command 1229 if( sem_wait( &semaphore ) ) 1230 { 1231 printf("\n[ksh error] cannot found semafore\n" ); 1232 exit( 1 ); 1233 } 1234 else 1235 { 1236 strcpy( cmd , "load bin/user/transpose.elf" ); 1237 printf("[ksh] %s\n", cmd ); 1238 execute( cmd ); 1239 } 1240 // 1241 1242 1243 1244 /* 2. second direct command 1245 if( sem_wait( &semaphore ) ) 1246 { 1247 printf("\n[ksh error] cannot found semafore\n" ); 1248 exit( 1 ); 1249 } 1250 else 1251 { 1252 strcpy( cmd , "cat home/p_fft_dqt_16384_1_2" ); 1253 printf("[ksh] %s\n", cmd ); 1254 execute( cmd ); 1255 } 1249 /* direct command to help debug 1250 1251 int pid = getpid(); 1252 1253 if( pid == 3 ) 1254 { 1255 if( sem_wait( &semaphore ) ) 1256 { 1257 printf("\n[ksh %d] error : cannot found semafore\n" ); 1258 exit( 1 ); 1259 } 1260 else 1261 { 1262 strcpy( cmd , "load bin/user/tcp_server.elf" ); 1263 printf("[ksh] %s\n", cmd ); 1264 execute( cmd ); 1265 } 1266 } 1267 else if( getpid() == 4 ) 1268 { 1269 if( sem_wait( &semaphore ) ) 1270 { 1271 printf("\n[ksh %d] error : cannot found semafore\n" ); 1272 exit( 1 ); 1273 } 1274 else 1275 { 1276 strcpy( cmd , "load bin/user/tcp_client.elf" ); 1277 printf("[ksh] %s\n", cmd ); 1278 execute( cmd ); 1279 } 1280 } 1281 1256 1282 */ 1257 1283 … … 1294 1320 1295 1321 #if DEBUG_INTER 1296 unsigned int pid = getpid();1297 1322 snprintf( string , 128 , "[ksh] %s : request a new command", __FUNCTION__ ); 1298 1323 display_string( string ); … … 1327 1352 snprintf( string , 128 , "[ksh] %s : get command <%s>", __FUNCTION__, cmd ); 1328 1353 display_string( string ); 1329 display_vmm( 0 , 2 );1330 1354 #endif 1331 1355 // register command in log_entries[] array -
trunk/user/sort/sort.c
r656 r659 262 262 263 263 // compute number of working threads (one thread per core) 264 get_config( &x_size , &y_size , &ncores ); 264 hard_config_t config; 265 get_config( &config ); 266 x_size = config.x_size; 267 y_size = config.y_size; 268 ncores = config.ncores; 265 269 threads = x_size * y_size * ncores; 266 270 -
trunk/user/transpose/transpose.c
r657 r659 199 199 200 200 // get & check plat-form parameters 201 get_config( &x_size, 202 &y_size, 203 &ncores ); 201 hard_config_t config; 202 get_config( &config ); 203 x_size = config.x_size; 204 y_size = config.y_size; 205 ncores = config.ncores; 204 206 205 207 if((ncores != 1) && (ncores != 2) && (ncores != 4))
Note: See TracChangeset
for help on using the changeset viewer.