Changeset 626 for trunk/user
- Timestamp:
- Apr 29, 2019, 7:25:09 PM (6 years ago)
- Location:
- trunk/user
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/ksh.c
r625 r626 15 15 // The children processes are created by the <load> command, and are 16 16 // attached to the same TXT terminal as the parent KSH process. 17 // A child process can be lau ched in foreground or in background:17 // A child process can be launched in foreground or in background: 18 18 // . when the child process is launched in foreground, the KSH process loses 19 19 // the TXT terminal ownership, that is transfered to the child process. … … 391 391 if( argc < 2 ) 392 392 { 393 printf(" usage: display vmm cxy pid\n"394 " display sched cxy lid\n"393 printf(" usage: display vmm cxy pid\n" 394 " display sched cxy lid\n" 395 395 " display process cxy\n" 396 396 " display txt txtid\n" … … 398 398 " display chdev\n" 399 399 " display dqdt\n" 400 " display locks pid trdid\n"400 " display locks pid trdid\n" 401 401 " display barrier pid\n" 402 " display mapper path page_id nbytes\n"); 402 " display mapper path page nbytes\n" 403 " display fat page entries\n" 404 " display fat cxy 0\n"); 403 405 } 404 406 //////////////////////////////////// … … 558 560 { 559 561 printf(" error: cannot display page %d of mapper %s\n", page_id, argv[2] ); 562 } 563 } 564 } 565 /////////////////////////////////////////// 566 else if( strcmp( argv[1] , "fat" ) == 0 ) 567 { 568 if( argc != 4 ) 569 { 570 printf(" usage: display fat page_id nb_entries\n"); 571 } 572 else 573 { 574 unsigned int page_id = atoi(argv[2]); 575 unsigned int nb_entries = atoi(argv[3]); 576 577 if( display_fat( page_id, nb_entries ) ) 578 { 579 printf(" error: cannot display page %d of fat\n", page_id ); 560 580 } 561 581 } … … 1141 1161 } // end execute() 1142 1162 1163 1164 1143 1165 /////////////////////////////// 1144 1166 static void interactive( void ) … … 1156 1178 #endif 1157 1179 1158 /* 1159 // To lauch one or several commands without interactive mode1180 /* 1181 // Lauch one or several commands without interactive mode 1160 1182 1161 1183 // 1. first command … … 1167 1189 else 1168 1190 { 1169 printf("\n[ksh] load bin/user/pgcd.elf\n");1191 printf("\n[ksh] display fat 0 32\n"); 1170 1192 } 1171 1193 1172 strcpy( cmd , " load bin/user/pgcd.elf" );1194 strcpy( cmd , "display fat 0 32" ); 1173 1195 execute( cmd ); 1174 1196 … … 1181 1203 else 1182 1204 { 1183 printf("\n[ksh] l s home\n");1205 printf("\n[ksh] load bin/user/pgcd.elf\n"); 1184 1206 } 1185 1207 1186 strcpy( cmd , "l s home" );1208 strcpy( cmd , "load bin/user/pgcd.elf" ); 1187 1209 execute( cmd ); 1188 1210 -
trunk/user/pgcd/pgcd.c
r625 r626 12 12 #include <almosmkh.h> 13 13 14 #define INSTRUMENTATION 0 15 #define IDBG 0 16 14 17 ///////////////// 15 18 void main( void ) … … 17 20 int opx; 18 21 int opy; 22 int x; 23 int y; 19 24 unsigned long long cycle; 20 25 unsigned int cxy; … … 24 29 get_core( &cxy , &lid ); 25 30 26 printf( "\n \n[pgcd] starts on core[%x,%d] / cycle %d\n",31 printf( "\n[pgcd] starts on core[%x,%d] / cycle %d\n\n", 27 32 cxy , lid , (unsigned int)cycle ); 28 33 29 while (1) 34 // get operand X 35 printf("operand X = "); 36 opx = get_uint32(); 37 printf("\n"); 38 39 // get operand Y 40 printf("operand Y = "); 41 opy = get_uint32(); 42 printf("\n"); 43 44 // check operands 45 if( (opx == 0) || (opy == 0) ) 30 46 { 31 printf("\n*******************\n"); 32 printf("operand X = "); 33 opx = get_uint32(); 34 printf("\n"); 35 printf("operand Y = "); 36 opy = get_uint32(); 37 printf("\n"); 47 printf("\n[pgcd error] operands must be strictly positive\n"); 48 exit(0); 49 } 38 50 39 if( (opx == 0) || (opy == 0) ) 40 { 41 printf("operands must be positive and larger than 0 => exit\n"); 42 exit( 0 ); 43 } 44 else 45 { 46 while (opx != opy) 47 { 48 if(opx > opy) opx = opx - opy; 49 else opy = opy - opx; 50 } 51 printf("pgcd = %d", opx); 52 } 51 // compute PGCD 52 x = opx; 53 y = opy; 54 while (x != y) 55 { 56 if(x > y) x = x - y; 57 else y = y - x; 53 58 } 59 60 // display result 61 printf("pgcd = %d\n", x); 62 63 #if INSTRUMENTATION 64 65 char name[64]; 66 char path[128]; 67 68 // build a file name from X and Y values 69 snprintf( name , 64 , "pgcd_%d_%d", opx, opy ); 70 71 // build file pathname 72 snprintf( path , 128 , "home/%s" , name ); 73 74 #if IDBG 75 idbg(); 76 #endif 77 78 // open file 79 FILE * stream = fopen( path , NULL ); 80 81 if( stream == NULL ) 82 { 83 printf("\n[pgcd error] cannot open instrumentation file <%s>\n", name ); 84 exit(0); 85 } 86 87 printf("\n[pgcd] file %s successfully open\n", path); 88 89 #if IDBG 90 idbg(); 91 #endif 92 93 // register results to file 94 int ret = fprintf( stream , "pgcd( %d , %d ) = %d\n", opx, opy, x ); 95 96 if( ret < 0 ) 97 { 98 printf("\n[pgcd error] cannot write to instrumentation file <%s>\n", name ); 99 exit(0); 100 } 101 102 printf("\n[pgcd] file %s successfully written\n", path); 103 104 display_mapper( path , 0 , 64 ); 105 106 // close instrumentation file 107 108 #if IDBG 109 idbg(); 110 #endif 111 112 if( fclose( stream ) ) 113 { 114 printf("\n[pgcd error] cannot close the file <%s>\n", name ); 115 exit(0); 116 } 117 118 printf("\n[pgcd] file %s successfully closed\n", path); 119 120 #endif 121 122 exit(0); 123 54 124 } // end pgcd 55 125 -
trunk/user/sort/sort.c
r625 r626 29 29 #include <hal_macros.h> 30 30 31 #define ARRAY_LENGTH 256// number of items31 #define ARRAY_LENGTH 1024 // number of items 32 32 #define MAX_THREADS 1024 // 16 * 16 * 4 33 33 … … 38 38 #define CHECK_RESULT 0 // for debug 39 39 #define INSTRUMENTATION 1 // register computation times on file 40 #define IDBG 0 // activate interactive debug in main 40 41 41 42 ///////////////////////////////////////////////////////////// … … 439 440 #if INSTRUMENTATION 440 441 441 char name[64]; 442 char path[128]; 442 char name[64]; 443 char path[128]; 444 unsigned long long instru_cycle; 443 445 444 446 // build a file name from n_items / n_clusters / n_cores … … 461 463 name, sequencial, parallel ); 462 464 465 #if IDBG 466 idbg(); 467 #endif 468 463 469 // open file 470 get_cycle( &instru_cycle ); 464 471 FILE * stream = fopen( path , NULL ); 472 465 473 if( stream == NULL ) 466 474 { 467 printf("\n[sort error] cannot open instrumentation file <%s>\n", name);475 printf("\n[sort error] cannot open instrumentation file <%s>\n", path ); 468 476 exit(0); 469 477 } 470 478 471 printf("\n[sort] file %s successfully open\n", path); 479 printf("\n[sort] file <%s> open at cycle %d\n", path, (unsigned int)instru_cycle ); 480 481 #if IDBG 482 idbg(); 483 #endif 472 484 473 485 // register results to file 486 get_cycle( &instru_cycle ); 474 487 int ret = fprintf( stream , "\n----- %s -----\n" 475 488 " - sequencial : %d cycles\n" … … 477 490 if( ret < 0 ) 478 491 { 479 printf("\n[sort error] cannot write to instrumentation file <%s>\n", name);492 printf("\n[sort error] cannot write to instrumentation file <%s>\n", path ); 480 493 exit(0); 481 494 } 482 495 483 printf("\n[sort] file %s successfully written\n", path); 496 printf("\n[sort] file <%s> written at cycle %d\n", path, (unsigned int)instru_cycle ); 497 498 #if IDBG 499 idbg(); 500 #endif 484 501 485 502 // close instrumentation file 486 487 if( fclose( stream ) ) 488 { 489 printf("\n[sort error] cannot close the file <%s>\n", name ); 503 get_cycle( &instru_cycle ); 504 ret = fclose( stream ); 505 506 if( ret ) 507 { 508 printf("\n[sort error] cannot close instrumentation file <%s>\n", path ); 490 509 exit(0); 491 510 } 492 511 493 printf("\n[sort] file %s successfully closed\n", path);512 printf("\n[sort] file <%s> closed at cycle %d\n", path, (unsigned int)instru_cycle ); 494 513 495 514 #endif
Note: See TracChangeset
for help on using the changeset viewer.