Changeset 446 for trunk/user


Ignore:
Timestamp:
Jun 19, 2018, 5:12:57 PM (6 years ago)
Author:
alain
Message:

miscelaneous...

Location:
trunk/user
Files:
3 edited

Legend:

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

    r445 r446  
    2020    printf( "\n[IDBG] starts at cycle %d\n", (unsigned int)cycle );
    2121
    22     while (1)
    23     {
    24 
    25         ///////
    26         idbg();
    27         ///////
    28     }
     22    ///////
     23    idbg();
     24    ///////
    2925
    3026    get_cycle( &cycle );
  • trunk/user/ksh/ksh.c

    r445 r446  
    44// Author :  Alain Greiner
    55///////////////////////////////////////////////////////////////////////////////
    6 // This single thread application implement a simple shell for ALMOS-MKH.
     6// This applications implement a minimal shell for ALMOS-MKH.
     7// This user process contains two POSIX threads:
     8// - the "main" thread contains the infinite loop implementing
     9//   the children processes termination monitoring (children processes
     10//   are created by the <load> command and attached to the KSH TXT terminal).
     11// - the "interactive" thread contains the infinite loop implementing
     12//   the command interpreter attached to the TXT terminal.
    713///////////////////////////////////////////////////////////////////////////////
    814
     
    5359unsigned int    ptr;                      // read pointer in log_entries[]
    5460
     61pthread_attr_t  attr;                     // monitor thread attributes
     62
    5563////////////////////////////////////////////////////////////////////////////////
    5664//         Shell  Commands
     
    100108        }
    101109
    102         // set terminating '0' XXX
     110        // set terminating '0'
    103111        buf[size-1] = 0;
    104112
     
    449457    else                        // it is the parent KSH : ret_fork is the new process PID
    450458    {
    451         // give back terminal ownership to KSH if new process created in background /
    452         // wait new process completion before returning to command interpreter otherwise
     459        // give back terminal ownership to KSH
     460        // when new process created in background
    453461        if( background )   fg( ksh_pid );
    454         else               wait( &status );
    455462
    456463        // return to command interpreter
     
    715722                }
    716723        }
    717 }
    718 
    719 ///////////////////////////////////
    720 int main( int argc , char *argv[] )
     724}  // end parse()
     725
     726/////////////////////////
     727static void interactive()
    721728{
    722729        char         c;                                           // read character
    723730        char         buf[CMD_MAX_SIZE];           // buffer for one command
    724         unsigned int count = 0;                           // pointer in buf
     731        unsigned int count;                               // pointer in buf
    725732        unsigned int i;                                           // index for loops
    726733
     
    732739        };
    733740
    734     // log buffer initialisation
    735         memset( &log_entries , 0, sizeof(log_entries));
    736         ptw   = 0;
    737         ptr   = 0;
    738 
    739         printf( "\n\n~~~ shell ~~~\n\n" );
    740 
    741         // command buffer initialisation
     741        // initialize command buffer
    742742        memset( buf, 0x20 , sizeof(buf) );
    743743        count = 0;
     
    760760
    761761// @@@
    762 // parse("load /bin/user/hello.elf");
     762parse("load /bin/user/idbg.elf");
    763763// @@@
    764764
     
    814814                                        state = ESCAPE;
    815815                                }
    816                                 else if (c == 0x03)     // ^C  => cancel current command
    817                                 {
    818                                         for (i = 0; i < count; i++) printf("\b \b");
    819                                         for (i = 0; i < sizeof(buf); i++) buf[i] = 0x20;
    820                                         count = 0;
    821                                 }
    822816                                else                                     // register character in command buffer
    823817                                {
     
    910904                }
    911905        }
     906}  // end interactive()
     907
     908///////////////////////////////////
     909int main( int argc , char *argv[] )
     910{
     911    unsigned int cxy;             // owner cluster identifier for this KSH process
     912    unsigned int lid;             // core identifier for this KSH main thread
     913    int          status;          // child process termination status
     914    int          pid;             // chils process identifier
     915    pthread_t    trdid;           // kernel allocated index for interactive thread
     916
     917    // initialize log buffer
     918        memset( &log_entries , 0, sizeof(log_entries));
     919        ptw   = 0;
     920        ptr   = 0;
     921
     922    get_core( &cxy , & lid );
     923        printf( "\n\n~~~ KSH on core[%x,%d] ~~~\n\n", cxy , lid );
     924
     925    // initialize interactive thread attributes
     926    attr.attributes = PT_ATTR_DETACH | PT_ATTR_CLUSTER_DEFINED;
     927    attr.cxy        = cxy;
     928
     929    // lauch the interactive thread
     930    pthread_create( &trdid,
     931                    &attr,
     932                    &interactive,   // entry function
     933                    NULL );
     934   
     935    // enter infinite loop monitoring children processes termination
     936    while( 1 )
     937    {
     938        pid = wait( &status );
     939
     940#if 0
     941        if     ( WIFEXITED  (status) ) printf("\n[KSH] process %x exited\n" , pid );
     942        else if( WIFSIGNALED(status) ) printf("\n[KSH] process %x killed\n" , pid );
     943        else if( WIFSTOPPED (status) ) printf("\n[KSH] process %x stopped\n", pid );
     944        else                           printf("\n[KSH] process %x strange\n", pid ); 
     945#endif
     946
     947    }
    912948}  // end main()
    913949
     950
  • trunk/user/pgcd/pgcd.c

    r445 r446  
    3333        if( (opx == 0) || (opy == 0) )
    3434        {
    35            printf("operands must be positive and larger than 0\n");
     35           printf("operands must be positive and larger than 0 => exit\n");
     36           exit( 0 );
    3637        }
    3738        else
Note: See TracChangeset for help on using the changeset viewer.