Changeset 574 for trunk/user/ksh
- Timestamp:
- Oct 5, 2018, 12:26:30 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/user/ksh/ksh.c
r503 r574 8 8 // This user KSH process contains two POSIX threads: 9 9 // - the "main" thread contains the infinite loop implementing 10 // the children processes termination monitoring, using the wait syscall.10 // the children processes termination monitoring, using the wait() syscall. 11 11 // - the "interactive" thread contains the infinite loop implementing the command 12 12 // interpreter attached to the TXT terminal, and handling one KSH command … … 49 49 #define LOG_DEPTH (32) // max number of registered commands 50 50 #define MAX_ARGS (32) // max number of arguments in a command 51 #define FIFO_SIZE (1024) // FIFO depth for recursive ls 52 53 #define KSH_DEBUG 0 51 52 #define MAIN_DEBUG 0 54 53 #define CMD_LOAD_DEBUG 0 55 54 … … 821 820 } // end parse() 822 821 823 ///////////////////////// 822 /////////////////////////////// 824 823 static void interactive( void ) 825 824 { … … 831 830 unsigned int state; // escape sequence state 832 831 833 /* This can be used to removeinteractive mode834 835 for( i=1 ; 1 ; i += 2)832 /* This can be used to simplify debug, as it avoids interactive mode 833 834 for( i=1 ; 1 ; i++ ) 836 835 { 837 836 if( sem_wait( &semaphore ) ) … … 842 841 else 843 842 { 844 printf("\n[ksh] %d for sort\n", i ); 845 } 846 strcpy( buf , "load /bin/user/sort.elf" ); 847 parse( buf ); 848 849 if( sem_wait( &semaphore ) ) 850 { 851 printf("\n[ksh error] cannot found semafore\n" ); 852 exit( 1 ); 853 } 854 else 855 { 856 printf("\n[ksh] %d for fft\n", i+1 ); 843 printf("\n[ksh] %d for fft\n", i ); 857 844 } 858 845 strcpy( buf , "load /bin/user/fft.elf" ); … … 1047 1034 } // end interactive() 1048 1035 1049 ////////// 1036 //////////////// 1050 1037 int main( void ) 1051 1038 { … … 1067 1054 get_core( &cxy , &lid ); 1068 1055 1069 // initializes the semaphore used to unblock the interactive thread 1056 #if MAIN_DEBUG 1057 printf("\n[ksh] main started on core[%x,%d]\n", cxy , lid ); 1058 #endif 1059 1060 // initializes the semaphore used to synchronize with interactive thread 1070 1061 if ( sem_init( &semaphore , 0 , 1 ) ) 1071 1062 { … … 1074 1065 } 1075 1066 1067 #if MAIN_DEBUG 1068 printf("\n[ksh] main initialized semaphore\n" ); 1069 #endif 1070 1076 1071 // initialize interactive thread attributes 1077 1072 attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED; … … 1083 1078 &interactive, // entry function 1084 1079 NULL ); 1080 #if MAIN_DEBUG 1081 printf("\n[ksh] main launched interactive thread => wait children termination\n" ); 1082 #endif 1085 1083 1086 1084 // enter infinite loop monitoring children processes termination … … 1090 1088 child_pid = wait( &status ); 1091 1089 1092 #if KSH_DEBUG1093 if( WIFEXITED (status) ) printf("\n[ KSH] child process %x exited\n", child_pid );1094 if( WIFSIGNALED(status) ) printf("\n[ KSH] child process %x killed\n" , child_pid );1095 if( WIFSTOPPED (status) ) printf("\n[ KSH] child process %x stopped\n", child_pid );1090 #if MAIN_DEBUG 1091 if( WIFEXITED (status) ) printf("\n[ksh] child process %x exit\n" , child_pid ); 1092 if( WIFSIGNALED(status) ) printf("\n[ksh] child process %x killed\n" , child_pid ); 1093 if( WIFSTOPPED (status) ) printf("\n[ksh] child process %x stopped\n", child_pid ); 1096 1094 #endif 1097 1095
Note: See TracChangeset
for help on using the changeset viewer.