Changeset 626 for trunk/libs


Ignore:
Timestamp:
Apr 29, 2019, 7:25:09 PM (6 years ago)
Author:
alain
Message:

This version has been tested on the sort multithreaded application
for TSAR_IOB architectures ranging from 1 to 8 clusters.
It fixes three bigs bugs:
1) the dev_ioc device API has been modified: the dev_ioc_sync_read()
and dev_ioc_sync_write() function use now extended pointers on the
kernel buffer to access a mapper stored in any cluster.
2) the hal_uspace API has been modified: the hal_copy_to_uspace()
and hal_copy_from_uspace() functions use now a (cxy,ptr) couple
to identify the target buffer (equivalent to an extended pointer.
3) an implementation bug has been fixed in the assembly code contained
in the hal_copy_to_uspace() and hal_copy_from_uspace() functions.

Location:
trunk/libs
Files:
4 edited

Legend:

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

    r623 r626  
    199199}  // end get_uint32()
    200200
     201//////////////////////////////
     202int get_string( char * string,
     203                int    maxlen )
     204{
     205    int c;
     206    int done   = 0;
     207    int length = 0;
     208
     209    while( done == 0 )
     210    {
     211        // check buffer overflow
     212        if( length >= maxlen-1 )
     213        {
     214            return -1;                      // return failure   
     215        }
     216
     217        // read one character
     218        c = getchar();
     219
     220        // analyse this character
     221        if ( (c >= 0x20) && (c < 0x7F) )    // printable character
     222        {
     223            putchar( c );                   // echo
     224            string[length] = (char)c;       // register character in string
     225            length++;                       // update length
     226        }
     227        else if (c == 0x0A)                 // LF character marks end of string
     228        {
     229            done = 1;
     230        }
     231        else if ( (c == 0x7F) ||            // DEL character
     232                  (c == 0x08) )             // BS  character
     233        {
     234            if ( length > 0 )
     235            {
     236                length--;         
     237                printf("\b \b");            // BS /  / BS
     238            }
     239        }
     240        else if ( c == 0 )                  // EOF character
     241        {
     242            return -1;                      // return failure
     243        }
     244    }
     245
     246    // set NUL character in string and return success
     247    string[length] = 0;
     248    return 0;
     249
     250}  // end get_string()
     251
    201252
    202253///////////////    non standard debug functions    //////////////////////////
     
    298349}
    299350
     351///////////////////////////////////////
     352int display_fat( unsigned int  page_id,
     353                 unsigned int  nb_entries )
     354{
     355    return hal_user_syscall( SYS_DISPLAY,
     356                             DISPLAY_FAT,
     357                             (reg_t)page_id,
     358                             (reg_t)nb_entries, 0 );
     359}
     360
    300361///////////////////////////////
    301362int trace( unsigned int active,
     
    313374{
    314375   char          cmd;
    315    unsigned int  cxy;
    316    unsigned int  lid;
    317    unsigned int  txt;
    318    unsigned int  pid;
    319    unsigned int  trdid;
    320    unsigned int  active;
    321376
    322377   while( 1 )
    323378   {
     379        // display prompt
    324380        printf("\n[idbg] cmd = ");
     381
     382        // get a one character command
    325383        cmd = (char)getchar();
    326384
    327         if( cmd == 'h' )
    328         {
    329             printf("h\n"
    330                    "p : display on TXT0 process descriptors in cluster[cxy]\n"
    331                    "s : display on TXT0 scheduler state for core[cxy,lid]\n"
    332                    "v : display on TXT0 VMM state for process[cxy,pid]\n"
    333                    "t : display on TXT0 process decriptors attached to TXT[tid]\n"
    334                    "b : display on TXT0 busylocks taken by thread[pid,trdid]\n"
    335                    "q : display on TXT0 DQDT state\n"
    336                    "y : activate/desactivate trace for core[cxy,lid]\n"
    337                    "x : force calling process to exit\n"
    338                    "c : resume calling process execution\n"
    339                    "h : list supported commands\n");
    340         }
     385        // display all busylocks owned by thread(pid,trdid)
     386        if( cmd == 'b' )
     387        {
     388            printf("b / pid = ");
     389            unsigned int pid = get_uint32();
     390            printf(" / trdid = ");
     391            unsigned int trdid = get_uint32();
     392            display_busylocks( pid , trdid );
     393        }
     394        // return to calling process
     395        else if( cmd == 'c' )
     396        {
     397            printf("c\n");
     398            break;
     399        }
     400        // display FAT mapper(page,entries)
     401        else if( cmd == 'f' )
     402        {
     403            printf("f / page = ");
     404            unsigned int page = get_uint32();
     405            printf(" / entries = ");
     406            unsigned int entries = get_uint32();
     407            display_fat( page , entries );
     408        }
     409        // list all supported commands
     410        else if( cmd == 'h' )
     411        {
     412            printf("h\n"
     413                   "- b : display on TXT0 busylocks taken by thread[pid,trdid]\n"
     414                   "- c : resume calling process execution\n"
     415                   "- f : display on TXT0 FAT mapper[page,entries]\n"
     416                   "- h : list of supported commands\n"
     417                   "- m : display on TXT0 mapper[path,page,nbytes]\n"
     418                   "- p : display on TXT0 process descriptors in cluster[cxy]\n"
     419                   "- q : display on TXT0 DQDT state\n"
     420                   "- s : display on TXT0 scheduler state for core[cxy,lid]\n"
     421                   "- t : display on TXT0 process decriptors attached to TXT[tid]\n"
     422                   "- v : display on TXT0 VMM state for process[cxy,pid]\n"
     423                   "- x : force calling process to exit\n"
     424                   "- y : activate/desactivate trace for core[cxy,lid]\n"
     425                   );
     426        }
     427        // display MAPPER(path,page,nbytes)
     428        else if( cmd == 'm' )
     429        {
     430            char  path[128];
     431            printf("m / path = ");
     432            int error = get_string( path , 128 );
     433            printf(" / page = ");
     434            unsigned int page = get_uint32();
     435            printf(" / nbytes = ");
     436            unsigned int nbytes = get_uint32();
     437            if( error == 0 ) display_mapper( path , page , nbytes );
     438        }
     439        // display all processes in cluster(cxy)
    341440        else if( cmd == 'p' )
    342441        {
    343442            printf("p / cxy = ");
    344             cxy = get_uint32();
     443            unsigned int cxy = get_uint32();
    345444            display_cluster_processes( cxy , 0 );
    346445        }
    347         else if( cmd == 's' )
    348         {
    349             printf("s / cxy = ");
    350             cxy = get_uint32();
    351             printf(" / lid = ");
    352             lid = get_uint32();
    353             display_sched( cxy , lid );
    354         }
    355         else if( cmd == 'v' )
    356         {
    357             printf("v / cxy = ");
    358             cxy = get_uint32();
    359             printf(" / pid = ");
    360             pid = get_uint32();
    361             display_vmm( cxy , pid );
    362         }
    363         else if( cmd == 't' )
    364         {
    365             printf("t / txt_id = ");
    366             txt = get_uint32();
    367             display_txt_processes( txt );
    368         }
     446        // display DQDT
    369447        else if( cmd == 'q' )
    370448        {
     
    372450            display_dqdt();
    373451        }
    374         else if( cmd == 'y' )
    375         {
    376             printf("y / active = ");
    377             active = get_uint32();
    378             printf(" / cxy = ");
    379             cxy    = get_uint32();
     452        // display scheduler state for core(cxy,lid)
     453        else if( cmd == 's' )
     454        {
     455            printf("s / cxy = ");
     456            unsigned int cxy = get_uint32();
    380457            printf(" / lid = ");
    381             lid    = get_uint32();
    382             trace( active , cxy , lid );
    383         }
    384         else if( cmd == 'b' )
    385         {
    386             printf("b / pid = ");
    387             pid = get_uint32();
    388             printf(" / trdid = ");
    389             trdid = get_uint32();
    390             display_busylocks( pid , trdid );
    391         }
     458            unsigned int lid = get_uint32();
     459            display_sched( cxy , lid );
     460        }
     461        // display all processes attached to TXT(txt_id)
     462        else if( cmd == 't' )
     463        {
     464            printf("t / txt_id = ");
     465            unsigned int txt_id = get_uint32();
     466            display_txt_processes( txt_id );
     467        }
     468        // display vmm state for process(cxy, pid)
     469        else if( cmd == 'v' )
     470        {
     471            printf("v / cxy = ");
     472            unsigned int cxy = get_uint32();
     473            printf(" / pid = ");
     474            unsigned int pid = get_uint32();
     475            display_vmm( cxy , pid );
     476        }
     477        // force the calling process to exit
    392478        else if( cmd == 'x' )
    393479        {
     
    395481            exit( 0 );
    396482        }
    397         else if( cmd == 'c' )
    398         {
    399             printf("c\n");
    400             break;
    401         }
    402     }
     483        // activate scheduler trace for core(cxy,lid)
     484        else if( cmd == 'y' )
     485        {
     486            printf("y / active = ");
     487            unsigned int active = get_uint32();
     488            printf(" / cxy = ");
     489            unsigned int cxy    = get_uint32();
     490            printf(" / lid = ");
     491            unsigned int lid    = get_uint32();
     492            trace( active , cxy , lid );
     493        }
     494    }  // en while
    403495}  // end idbg()
    404496
  • trunk/libs/libalmosmkh/almosmkh.h

    r625 r626  
    238238int display_barrier( unsigned int pid );
    239239
     240/***************************************************************************************
     241 * This debug syscall displays on the kernel terminal TXT0 the content of one given
     242 * page of the FAT mapper.
     243 * It can be called by any thread running in any cluster.
     244 ***************************************************************************************
     245 * @ page_id    : page index in file.
     246 * @ nb_entries : number of bytes to display.
     247 * @ return 0 if success / return -1 if page not found.
     248 **************************************************************************************/
     249int display_fat( unsigned int page_id,
     250                 unsigned int nb_entries );
     251
    240252/*****************************************************************************************
    241253* This debug syscall is used to activate / desactivate the context switches trace
  • trunk/libs/mini-libc/unistd.c

    r625 r626  
    6666}
    6767
     68//////////////////
     69int fsync( int fd )
     70{
     71    return hal_user_syscall( SYS_FSYNC,
     72                             (reg_t)fd, 0, 0, 0 );
     73}
     74
    6875/////////////////////////////
    6976int getcwd( char       * buf,
     
    7582}
    7683
    77 ////////////
     84//////////////////
    7885int getpid( void )
    7986{
     
    132139}
    133140
     141/////////////////
     142void sync( void )
     143{
     144    hal_user_syscall( SYS_SYNC, 0, 0, 0, 0 );
     145}
     146
    134147///////////////////////////////////
    135148int unlink( const char * pathname )
  • trunk/libs/mini-libc/unistd.h

    r610 r626  
    3535
    3636/*****************************************************************************************
    37  * This function sets a timer to deliver the signal SIGALRM to the calling process,
     37 * This function implements the "alarm" system call.
     38 * sets a timer to deliver the signal SIGALRM to the calling process,
    3839 * after the specified number of seconds.
    3940 * If an alarm has already been set with alarm() but has not been delivered,
     
    4849
    4950/*****************************************************************************************
    50  * This function change the current working directory in the reference process descriptor.
     51 * This function implements the "chdir" system call.
     52 * It changes the current working directory in the reference process descriptor.
    5153 *****************************************************************************************
    5254 * @ pathname   : pathname (can be relative or absolute).
     
    5658
    5759/*****************************************************************************************
    58  * This function release the memory allocated for the file descriptor identified by
    59  * the <fd> argument, and remove the fd array_entry in all process descriptor copies.
     60 * This function implements the "close" system call.
     61 * It releases the memory allocated for the file identified by the <fd> argument,
     62 * and remove the fd array_entry in all process descriptor copies.
    6063 *****************************************************************************************
    6164 * @ fd   : file descriptor index in fd_array.
     
    6568
    6669/*****************************************************************************************
    67  * This function implement the "exec" system call on the user side.
     70 * This function implement the "exec" system call.
    6871 * It creates, in the same cluster as the calling thread, a new process descriptor,
    6972 * and a new associated main thread descriptor, executing a new memory image defined
     
    8790
    8891/*****************************************************************************************
    89  * This function implement the "fork" system call on the user side.
     92 * This function implement the "fork" system call.
    9093 * The calling process descriptor (parent process), and the associated thread descriptor
    9194 * are replicated in a - likely - remote cluster, that becomes the new process owner.
     
    103106
    104107/*****************************************************************************************
    105  * This function returns the pathname of the current working directory.
     108 * This function implements the "fsync" system call.
     109 * It causes all the modified data and attributes of file identified by the <fd> argument
     110 * to be copied from the file mapper and file descriptor to the IOC device.
     111 *****************************************************************************************
     112 * @ fd   : file descriptor index in fd_array.
     113 * @ return 0 if success / returns -1 if failure.
     114 ****************************************************************************************/
     115int fsync( int fd );
     116
     117/*****************************************************************************************
     118 * This function implements the "getcwd" system call.
     119 * It returns the pathname of the current working directory.
    106120 *****************************************************************************************
    107121 * buf     : buffer addres in user space.
     
    113127
    114128/*****************************************************************************************
    115  * This function implements the "getpid" system call on the user side.
     129 * This function implements the "getpid" system call.
     130 * It returns the process identifier.
    116131 *****************************************************************************************
    117132 * @ returns the process PID for the calling thread process.
     
    120135
    121136/*****************************************************************************************
    122  * This function test whether a file descriptor refers to a terminal.
     137 * This function implements the "isatty" system call.
     138 * It test whether a file descriptor refers to a terminal.
    123139 *****************************************************************************************
    124140 * @ fd   : file descriptor index in fd_array.
     
    128144
    129145/*****************************************************************************************
    130  * This function repositions the offset of the file descriptor identified by <fd>,
     146 * This function implements the "lseek" system call.
     147 * It repositions the offset of the file descriptor identified by <fd>,
    131148 * according to the operation type defined by the <whence> argument.
    132149 *****************************************************************************************
     
    141158
    142159/*****************************************************************************************
    143  * This function stops the calling process until any signal is received.
     160 * This function implements the "pause" system call.
     161 * It stops the calling process until a signal is received.
    144162 *****************************************************************************************
    145163 * @ return 0 if success / returns -1 if failure.
     
    148166
    149167/*****************************************************************************************
    150  * This function creates in the calling thread cluster an unnamed pipe, and two
    151  * (read and write) file descriptors to access this pipe. The calling function must pass
    152  * the pointer on the fd[] array.
     168 * This function implements the "pipe" system call.
     169 * It creates in the calling thread cluster an unnamed pipe, and two (read and write)
     170 * file descriptors to access this pipe. The argument is a pointer a fd[] array.
    153171 * TODO not implemented yet...
    154172 *****************************************************************************************
     
    160178
    161179/*****************************************************************************************
    162  * This function read bytes from an open file identified by the <fd> file descriptor.
     180 * This function implements the "read" system call.
     181 * It reads bytes from an open file identified by the <fd> file descriptor.
    163182 * This file can be a regular file or a character oriented device.
    164183 *****************************************************************************************
     
    173192
    174193/*****************************************************************************************
    175  * This function removes a directory file whose name is given by <pathname>.
    176  * The directory must not have any entries other than `.' and `..'.
     194 * This function implements the "rmdir" system call.
     195 * It removes a directory file whose name is given by <pathname>.
     196 * The directory must not contain any entries other than `.' and `..'.
    177197 *****************************************************************************************
    178198 * @ pathname   : pathname (can be relative or absolute).
     
    182202
    183203/*****************************************************************************************
    184  * This function removes a directory entry identified by the <pathname> from the
    185  * directory, and decrement the link count of the file referenced by the link.
     204 * This function implements the "sync" system call.
     205 * It forces all kernel mappers (file caches) to be copied to the IOC device.
     206 ****************************************************************************************/
     207void sync( void );
     208
     209/*****************************************************************************************
     210 * This function implements the "unlink" system call.
     211 * It removes a directory entry identified by the <pathname> from the parent directory,
     212 * and decrement the link count of the file referenced by the link.
    186213 * If the link count reduces to zero, and no process has the file open, then all resources
    187214 * associated with the file are released.  If one or more process have the file open when
     
    195222
    196223/*****************************************************************************************
    197  * This function writes bytes to an open file identified by the <fd> file descriptor.
     224 * This function implements the "write" system call.
     225 * It writes bytes to an open file identified by the <fd> file descriptor.
    198226 * This file can be a regular file or character oriented device.
    199227 *****************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.