Changeset 580 for trunk/libs/libalmosmkh


Ignore:
Timestamp:
Oct 8, 2018, 11:31:42 AM (5 years ago)
Author:
alain
Message:

1) Register the kernel process in the cluster manager local list.
2) Introduce a new service in idbg : display the set of busylocks taken by a given thread.

Location:
trunk/libs/libalmosmkh
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/libalmosmkh/almosmkh.c

    r573 r580  
    8888}
    8989
    90 ////////////
    91 int getint( void )
     90///////////////////////////////
     91unsigned int get_uint32( void )
    9292{
    9393    unsigned int  i;
    94     int           val;    // ASCII character value
     94    int           c;    // ASCII character value
    9595
    9696    unsigned char buf[32];
     97
    9798    unsigned int  save          = 0;
    98     unsigned int  dec           = 0;
     99    unsigned int  value         = 0;
    99100    unsigned int  done          = 0;
    100101    unsigned int  overflow      = 0;
    101102    unsigned int  length        = 0;
    102  
     103
    103104    // get characters
    104105    while (done == 0)
    105106    {
    106107        // read one character
    107         val = getchar();
    108 
    109         // analyse character
    110         if ((val > 0x2F) && (val < 0x3A))         // decimal character
    111         {
    112             buf[length] = (unsigned char)val;
     108        c = getchar();
     109
     110        // analyse this character
     111        if ( ((c > 0x2F) && (c < 0x3A)) ||                      // 0 to 9
     112             ((c > 0x40) && (c < 0x47)) ||                      // A to F
     113             ((c > 0x60) && (c < 0x67)) ||                      // a to f
     114             (((c == 0x58) || (c == 0x78)) && (length == 1)) )  // X or x
     115        {
     116            putchar( c );                       // echo
     117            if ( c > 0x60 )  c = c - 0x20;      // to upper case
     118            buf[length] = (unsigned char)c;
    113119            length++;                     
    114             putchar( val );                       // echo
    115         }
    116         else if (val == 0x0A)                     // LF character
     120        }
     121        else if (c == 0x0A)                                     // LF character
    117122        {
    118123            done = 1;
    119124        }
    120         else if ( (val == 0x7F) ||                // DEL character
    121                   (val == 0x08) )                 // BS  character
     125        else if ( (c == 0x7F) ||                                // DEL character
     126                  (c == 0x08) )                                 // BS  character
    122127        {
    123128            if ( length > 0 )
    124129            {
    125130                length--;         
    126                 printf("\b \b");                  // BS /  / BS
     131                printf("\b \b");                // BS /  / BS
    127132            }
    128133        }
    129         else if ( val == 0 )                      // EOF
     134        else if ( c == 0 )                                      // EOF character
    130135        {
    131136            return -1;
     
    140145    }  // end while characters
    141146
    142     // string to int conversion with overflow detection 
     147    // string to int conversion with overflow detection
    143148    if ( overflow == 0 )
    144149    {
    145         for (i = 0; (i < length) && (overflow == 0) ; i++)
    146         {
    147             dec = dec * 10 + (buf[i] - 0x30);
    148             if (dec < save)  overflow = 1;
    149             save = dec;
     150        // test (decimal / hexa)
     151        if( (buf[0] == 0x30) && (buf[1] == 0x58) )     // hexadecimal input
     152        {
     153            for (i = 2; (i < length) && (overflow == 0) ; i++)
     154            {
     155                if( buf[i] < 0x40 ) value = (value << 4) + (buf[i] - 0x30);
     156                else                value = (value << 4) + (buf[i] - 0x37);
     157                if (value < save) overflow = 1;
     158                save = value;
     159            }
     160        }
     161        else                                           // decimal input
     162        {
     163            for (i = 0; (i < length) && (overflow == 0) ; i++)
     164            {
     165                value = (value * 10) + (buf[i] - 0x30);
     166                if (value < save) overflow = 1;
     167                save = value;
     168            }
    150169        }
    151170    }
     
    155174    {
    156175        // return value
    157         return dec;
     176        return value;
    158177    }
    159178    else
     
    171190        return 0;
    172191    }
    173 }  // end getint()
     192}  // end get_uint32()
    174193
    175194
     
    184203}
    185204
    186 ///////////////////////////////////
     205/////////////////////////////////////////////////////
    187206int display_vmm( unsigned int cxy, unsigned int pid )
    188207{
    189208    return hal_user_syscall( SYS_DISPLAY,
    190209                             DISPLAY_VMM,
    191                              (reg_t)pid,
    192                              (reg_t)cxy, 0 );
     210                             (reg_t)cxy,
     211                             (reg_t)pid, 0 );
    193212}
    194213
     
    211230}
    212231
    213 ///////////////////
     232////////////////////////////////////////
     233int display_busylocks( unsigned int pid,
     234                       unsigned int trdid )
     235{
     236    return hal_user_syscall( SYS_DISPLAY,
     237                             DISPLAY_BUSYLOCKS,
     238                             (reg_t)pid,
     239                             (reg_t)trdid, 0 );
     240}
     241
     242/////////////////////////
    214243int display_chdev( void )
    215244{
     
    258287   unsigned int  lid;
    259288   unsigned int  txt;
     289   unsigned int  pid;
     290   unsigned int  trdid;
    260291   unsigned int  active;
    261292
     
    270301                   "p : display on TXT0 process descriptors in cluster[cxy]\n"
    271302                   "s : display on TXT0 scheduler state for core[cxy,lid]\n"
    272                    "v : display on TXT0 VMM for calling process in cluster [cxy]\n"
     303                   "v : display on TXT0 VMM state for process[cxy,pid]\n"
    273304                   "t : display on TXT0 process decriptors attached to TXT[tid]\n"
     305                   "b : display on TXT0 busylocks taken by thread[pid,trdid]\n"
    274306                   "y : activate/desactivate trace for core[cxy,lid]\n"
    275307                   "x : force calling process to exit\n"
     
    280312        {
    281313            printf("p / cxy = ");
    282             cxy = getint();
     314            cxy = get_uint32();
    283315            display_cluster_processes( cxy );
    284316        }
     
    286318        {
    287319            printf("s / cxy = ");
    288             cxy = getint();
     320            cxy = get_uint32();
    289321            printf(" / lid = ");
    290             lid = getint();
     322            lid = get_uint32();
    291323            display_sched( cxy , lid );
    292324        }
     
    294326        {
    295327            printf("v / cxy = ");
    296             cxy = getint();
    297             display_vmm( cxy , (unsigned int)getpid() );
     328            cxy = get_uint32();
     329            printf(" / pid = ");
     330            pid = get_uint32();
     331            display_vmm( cxy , pid );
    298332        }
    299333        else if( cmd == 't' )
    300334        {
    301335            printf("t / txt_id = ");
    302             txt = getint();
     336            txt = get_uint32();
    303337            display_txt_processes( txt );
    304338        }
     
    306340        {
    307341            printf("y / active = ");
    308             active = getint();
     342            active = get_uint32();
    309343            printf(" / cxy = ");
    310             cxy    = getint();
     344            cxy    = get_uint32();
    311345            printf(" / lid = ");
    312             lid    = getint();
     346            lid    = get_uint32();
    313347            trace( active , cxy , lid );
     348        }
     349        else if( cmd == 'b' )
     350        {
     351            printf("b / pid = ");
     352            pid = get_uint32();
     353            printf(" / trdid = ");
     354            trdid = get_uint32();
     355            display_busylocks( pid , trdid );
    314356        }
    315357        else if( cmd == 'x' )
  • trunk/libs/libalmosmkh/almosmkh.h

    r478 r580  
    101101
    102102/***************************************************************************************
    103  * This function returns a positive integer fom the standard "stdin" stream.
     103 * This function returns an unsigned 32 bits integer from the standard "stdin" stream.
     104 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported.
    104105 ***************************************************************************************
    105106 * returns the integer value if success / returns -1 if failure.
    106107 **************************************************************************************/
    107 int getint( void );
     108unsigned int getint32( void );
    108109
    109110
Note: See TracChangeset for help on using the changeset viewer.