Changeset 574 for trunk/user/ksh/ksh.c


Ignore:
Timestamp:
Oct 5, 2018, 12:26:30 AM (6 years ago)
Author:
alain
Message:

Cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user/ksh/ksh.c

    r503 r574  
    88// This user KSH process contains two POSIX threads:
    99// - 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.
    1111// - the "interactive" thread contains the infinite loop implementing the command
    1212//   interpreter attached to the TXT terminal, and handling one KSH command
     
    4949#define LOG_DEPTH      (32)     // max number of registered commands
    5050#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
    5453#define CMD_LOAD_DEBUG      0
    5554
     
    821820}  // end parse()
    822821
    823 /////////////////////////
     822///////////////////////////////
    824823static void interactive( void )
    825824{
     
    831830        unsigned int   state;                   // escape sequence state
    832831
    833 /* This can be used to remove interactive mode
    834 
    835 for( i=1 ; 1 ; i += 2)
     832/* This can be used to simplify debug, as it avoids interactive mode
     833
     834for( i=1 ; 1 ; i++ )
    836835{
    837836    if( sem_wait( &semaphore ) )
     
    842841    else
    843842    {
    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 );
    857844    }
    858845    strcpy( buf , "load /bin/user/fft.elf" );
     
    10471034}  // end interactive()
    10481035
    1049 //////////
     1036////////////////
    10501037int main( void )
    10511038{
     
    10671054    get_core( &cxy , &lid );
    10681055
    1069     // initializes the semaphore used to unblock the interactive thread
     1056#if MAIN_DEBUG
     1057printf("\n[ksh] main started on core[%x,%d]\n", cxy , lid );
     1058#endif
     1059   
     1060    // initializes the semaphore used to synchronize with interactive thread
    10701061    if ( sem_init( &semaphore , 0 , 1 ) )
    10711062    {
     
    10741065    }
    10751066
     1067#if MAIN_DEBUG
     1068printf("\n[ksh] main initialized semaphore\n" );
     1069#endif
     1070   
    10761071    // initialize interactive thread attributes
    10771072    attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED;
     
    10831078                    &interactive,   // entry function
    10841079                    NULL );
     1080#if MAIN_DEBUG
     1081printf("\n[ksh] main launched interactive thread => wait children termination\n" );
     1082#endif
    10851083   
    10861084    // enter infinite loop monitoring children processes termination
     
    10901088        child_pid = wait( &status );
    10911089
    1092 #if KSH_DEBUG
    1093 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
     1091if( WIFEXITED  (status) ) printf("\n[ksh] child process %x exit\n"  , child_pid );
     1092if( WIFSIGNALED(status) ) printf("\n[ksh] child process %x killed\n" , child_pid );
     1093if( WIFSTOPPED (status) ) printf("\n[ksh] child process %x stopped\n", child_pid );
    10961094#endif
    10971095
Note: See TracChangeset for help on using the changeset viewer.