Changeset 588 for trunk/user/ksh
- Timestamp:
- Nov 1, 2018, 12:44:35 PM (6 years ago)
- Location:
- trunk/user/ksh
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/Makefile
r457 r588 16 16 -I$(LIBALMOSMKH_INCLUDE) \ 17 17 -I$(LIBSEMAPHORE_INCLUDE) \ 18 -I$(SHARED_INCLUDE) 18 -I$(SHARED_INCLUDE) \ 19 -I$(HAL_INCLUDE) 19 20 20 21 compile: dirs build/ksh.elf -
trunk/user/ksh/ksh.c
r574 r588 45 45 #include <almosmkh.h> 46 46 #include <semaphore.h> 47 #include <hal_macros.h> 47 48 48 49 #define CMD_MAX_SIZE (256) // max number of characters in one command … … 319 320 cxy = atoi(argv[2]); 320 321 321 if( display_cluster_processes( cxy ) )322 if( display_cluster_processes( cxy , 0 ) ) 322 323 { 323 324 printf(" error: illegal argument cxy = %x\n", cxy ); … … 465 466 char * pathname; // path to .elf file 466 467 unsigned int background; // background execution if non zero 467 468 if( (argc < 2) || (argc > 3) ) 469 { 470 printf(" usage: %s pathname [&] / argc = %d\n", argv[0], argc ); // @@@ 468 unsigned int placement; // placement specified if non zero 469 unsigned int cxy; // target cluster if placement specified 470 471 if( (argc < 2) || (argc > 4) ) 472 { 473 printf(" usage: %s pathname [cxy] [&]\n", argv[0] ); 471 474 return; 472 475 } … … 474 477 pathname = argv[1]; 475 478 476 if( argc == 3 ) background = (argv[2][0] == '&'); 477 else background = 0; 479 if( argc == 2 ) 480 { 481 background = 0; 482 placement = 0; 483 cxy = 0; 484 } 485 else if( argc == 3 ) 486 { 487 if( (argv[2][0] == '&') && (argv[2][1] == 0) ) 488 { 489 background = 1; 490 placement = 0; 491 cxy = 0; 492 } 493 else 494 { 495 background = 0; 496 placement = 1; 497 cxy = atoi( argv[2] ); 498 } 499 } 500 else // argc == 4 501 { 502 background = ( (argv[3][0] == '&') && (argv[3][1] == 0) ); 503 placement = 1; 504 cxy = atoi( argv[2] ); 505 } 478 506 479 507 // get KSH process PID … … 483 511 long long unsigned cycle; 484 512 get_cycle( &cycle ); 485 printf("\n @@@ %s : KSH PID %x before fork / path %s / background %d/ cycle %d\n",486 __FUNCTION__, ksh_pid, argv[1], background, (int)cycle );513 printf("\n[KSH] %s : ksh_pid %x / path %s / bg %d / place %d (%x) / cycle %d\n", 514 __FUNCTION__, ksh_pid, argv[1], background, placement, cxy, (int)cycle ); 487 515 #endif 516 517 // set target cluster if required 518 if( placement ) place_fork( cxy ); 488 519 489 520 // KSH process fork CHILD process … … 500 531 #if CMD_LOAD_DEBUG 501 532 get_cycle( &cycle ); 502 printf("\n @@@ %s : CHILD_PID%x after fork, before exec / cycle %d\n",533 printf("\n[KSH] %s : child_pid %x after fork, before exec / cycle %d\n", 503 534 __FUNCTION__ , getpid(), (int)cycle ); 504 535 #endif … … 509 540 #if CMD_LOAD_DEBUG 510 541 get_cycle( &cycle ); 511 printf("\n @@@ %s : CHILD_PID%x after exec / ret_exec %d / cycle %d\n",542 printf("\n[KSH] %s : child_pid %x after exec / ret_exec %d / cycle %d\n", 512 543 __FUNCTION__ , getpid(), ret_exec, (int)cycle ); 513 544 #endif … … 525 556 #if CMD_LOAD_DEBUG 526 557 get_cycle( &cycle ); 527 printf("\n @@@ %s : KSH_PID%x after fork / ret_fork %x / cycle %d\n",558 printf("\n[KSH] %s : ksh_pid %x after fork / ret_fork %x / cycle %d\n", 528 559 __FUNCTION__, getpid(), ret_fork, (int)cycle ); 529 560 #endif … … 636 667 637 668 } // end cmd_mv 669 670 671 //////////////////////////////////////////// 672 static void cmd_ps( int argc , char **argv ) 673 { 674 unsigned int x_size; 675 unsigned int y_size; 676 unsigned int ncores; 677 unsigned int x; 678 unsigned int y; 679 680 if (argc != 1) 681 { 682 printf(" usage: %s\n", argv[0]); 683 return; 684 } 685 686 // get platform config 687 get_config( &x_size , &y_size , &ncores ); 688 689 // scan all clusers 690 for( x = 0 ; x < x_size ; x++ ) 691 { 692 for( y = 0 ; y < y_size ; y++ ) 693 { 694 display_cluster_processes( HAL_CXY_FROM_XY(x,y), 1 ); // only owned processes 695 } 696 } 697 698 // release semaphore to get next command 699 sem_post( &semaphore ); 700 701 } // end cmd_ps() 638 702 639 703 ///////////////////////////////////////////// … … 758 822 { "mv", "move a file in file system", cmd_mv }, 759 823 { "pwd", "print current working directory", cmd_pwd }, 824 { "ps", "display all processes", cmd_ps }, 760 825 { "rm", "remove a file from file system", cmd_rm }, 761 826 { "rmdir", "remove a directory from file system", cmd_rmdir }, … … 830 895 unsigned int state; // escape sequence state 831 896 832 /* This can be used to simplify debug, as it avoids interactive mode 833 834 for( i=1 ; 1 ; i++ ) 835 { 836 if( sem_wait( &semaphore ) ) 837 { 838 printf("\n[ksh error] cannot found semafore\n" ); 839 exit( 1 ); 840 } 841 else 842 { 843 printf("\n[ksh] %d for fft\n", i ); 844 } 845 strcpy( buf , "load /bin/user/fft.elf" ); 846 parse( buf ); 897 898 /* To lauch one application without interactive mode 899 900 if( sem_wait( &semaphore ) ) 901 { 902 printf("\n[ksh error] cannot found semafore\n" ); 903 exit( 1 ); 847 904 } 905 else 906 { 907 printf("\n[ksh] for fft\n"); 908 } 909 910 strcpy( buf , "load /bin/user/fft.elf" ); 911 parse( buf ); 848 912 849 913 */ … … 1081 1145 printf("\n[ksh] main launched interactive thread => wait children termination\n" ); 1082 1146 #endif 1147 1148 // signal INIT process 1149 kill( 1 , SIGCONT ); 1083 1150 1084 1151 // enter infinite loop monitoring children processes termination
Note: See TracChangeset
for help on using the changeset viewer.