Changeset 435 for trunk/user


Ignore:
Timestamp:
Feb 20, 2018, 5:32:17 PM (6 years ago)
Author:
alain
Message:

Fix a bad bug in scheduler...

Location:
trunk/user
Files:
3 edited

Legend:

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

    r434 r435  
    3838    for( i = 1 ; i <  NB_TXT_CHANNELS ; i++ )
    3939    {
    40 
    41 snprintf( string , 64 , "@@@ before fork / iter = %d\n" , i );
    42 display_string( string );
    43 
    4440        // INIT process fork process CHILD[i]
    4541        ret_fork = fork();
    46 
    47 snprintf( string , 64 , "@@@ after fork / iter = %d / ret_fork = %d\n" , i , ret_fork );
    48 display_string( string );
    4942
    5043        if( ret_fork< 0 )   // error in fork
    5144        {
    5245            // INIT display error message on TXT0 terminal
    53             snprintf( string , 64 , "init cannot fork child[%d]\n" , i );
     46            snprintf( string , 64 ,
     47            "INIT cannot fork child[%d]\n" , i );
    5448            display_string( string );
    5549
     
    6559            {
    6660                // display error message on TXT0 terminal
    67                 snprintf( string , 64 , "child[%d] cannot exec ksh[%d]\n" , i , i );
     61                snprintf( string , 64 ,
     62                "CHILD[%d] cannot exec KSH[%d] / ret_exec = %d\n" , i , i , ret_exec );
    6863                display_string( string );
    69 
    70                 // CHILD[i] exit
    71                 // exit( 0 );
    7264            }
    7365        }
     
    7567        {
    7668             // INIT display CHILD[i] process PID
    77              snprintf( string , 64 , "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork );
     69             snprintf( string , 64 ,
     70             "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork );
    7871             display_string( string );
    79 
    80              // INIT delay
    81              int     x;
    82              for( x=0 ; x<DELAY_BETWEEN_FORK ; x++) asm volatile ("nop");
    83 
    84 /*
    85              // INIT wait exec completion by CHILD[i]
    86              while( 1 )
    87              {
    88                  // get terminating process PID
    89                  received_pid = wait( &status );
    90 
    91                  if( received_pid == ret_fork ) break;
    92                  else
    93                  {
    94                      snprintf( string , 64 ,
    95                      "expected_pid %d / received_pid %d" , ret_fork , received_pid  );
    96                      display_string( string );
    97                  }
    98              }
    99 
    100 */
    101              // INIT display string on kernel TXT0
    102              snprintf( string , 64 , "INIT created KSH[%d]\n", i );
    103              display_string( string );
    104 // @@@
    105 display_process( 0 );
    106 display_sched( 0 , 0 );
    107 // @@@
    10872        }
    10973
    11074    }
    11175
    112     // This blocking loop is only for debug, because KSH[i] processes
    113     // should never be killed, and INIT should never return from the wait() function.
     76    // This loop detects the termination of the KSH[i] processes,
     77    // to recreate these process when required.
    11478    while( 1 )
    11579    {
    116         // block on child process termination
    117         received_pid = wait( &status ); 
     80        // block on child processes termination
     81        received_pid = wait( &status );
    11882
    119         // display string to report unexpected KSH process termination
    120         snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid );
    121         display_string( string );
     83        if( WIFSTOPPED( status ) )                         // stopped => unblock it
     84        {
     85            // display string to report unexpected KSH process block
     86            snprintf( string , 64 , "KSH process %x unexpectedly stopped" , received_pid );
     87            display_string( string );
     88
     89        }
     90
     91        if( WIFSIGNALED( status ) || WIFEXITED( status ) )  // killed => recreate it
     92        {
     93            // display string to report unexpected KSH process termination
     94            snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid );
     95            display_string( string );
     96        }
    12297    }
    12398
  • trunk/user/ksh/ksh.c

    r434 r435  
    484484    unsigned int  lid;
    485485    unsigned int  pid;
     486    unsigned int  txt_id;
    486487
    487488    if( strcmp( argv[1] , "vmm" ) == 0 )
     
    526527            cxy = atoi(argv[2]);
    527528
    528         if( display_process( cxy ) )
     529        if( display_cluster_processes( cxy ) )
    529530        {
    530531            printf("  error: illegal argument cxy = %x\n", cxy );
    531532        }
    532533    }
     534    else if( strcmp( argv[1] , "txt" ) == 0 )
     535    {
     536        if( argc != 3 )
     537        {
     538                    printf("  usage: display txt txt_id\n");
     539                    return;
     540            }
     541
     542            txt_id = atoi(argv[2]);
     543
     544        if( display_txt_processes( txt_id ) )
     545        {
     546            printf("  error: illegal argument txt_id = %x\n", txt_id );
     547        }
     548    }
    533549    else if( strcmp( argv[1] , "vfs" ) == 0 )
    534550    {
     
    553569    else
    554570    {
    555         printf("  usage display (vmm/sched/process/vfs/chdev) [cxy] [lid]\n");
     571        printf("  usage: display (vmm/sched/process/vfs/chdev/txt) [arg2] [arg3]\n");
    556572    }
    557573}
     
    563579ksh_cmd_t cmd[] =
    564580{
    565         { "cat",     "display file content",                cmd_cat     },
    566         { "cd",      "change current directory",            cmd_cd      },
    567         { "cp",      "replicate a file in file system",     cmd_cp      },
    568     { "fg",      "put a process in foreground",         cmd_fg      },
    569     { "display", "display vmm/sched/process/vfs/chdev", cmd_display },
    570         { "load",    "load an user application",            cmd_load    },
    571         { "help",    "list available commands",             cmd_help    },
    572         { "kill",    "kill an application (all threads)",   cmd_kill    },
    573         { "log",     "list registered commands",            cmd_log     },
    574         { "ls",      "list directory entries",              cmd_ls      },
    575         { "mkdir",   "create a new directory",              cmd_mkdir   },
    576         { "mv",      "move a file in file system",          cmd_mv      },
    577         { "pwd",     "print current working directory",     cmd_pwd     },
    578         { "rm",      "remove a file from file system",      cmd_rm      },
    579         { "rmdir",   "remove a directory from file system", cmd_rmdir   },
    580         { NULL,     NULL,                                                                  NULL         }
     581        { "cat",     "display file content",                            cmd_cat     },
     582        { "cd",      "change current directory",                        cmd_cd      },
     583        { "cp",      "replicate a file in file system",                 cmd_cp      },
     584    { "fg",      "put a process in foreground",                     cmd_fg      },
     585    { "display", "display vmm/sched/process/vfs/chdev/txt",        cmd_display },
     586        { "load",    "load an user application",                        cmd_load    },
     587        { "help",    "list available commands",                         cmd_help    },
     588        { "kill",    "kill an application (all threads)",               cmd_kill    },
     589        { "log",     "list registered commands",                        cmd_log     },
     590        { "ls",      "list directory entries",                          cmd_ls      },
     591        { "mkdir",   "create a new directory",                          cmd_mkdir   },
     592        { "mv",      "move a file in file system",                      cmd_mv      },
     593        { "pwd",     "print current working directory",                 cmd_pwd     },
     594        { "rm",      "remove a file from file system",                  cmd_rm      },
     595        { "rmdir",   "remove a directory from file system",             cmd_rmdir   },
     596        { NULL,      NULL,                                                                              NULL        }
    581597};
    582598
  • trunk/user/sort/sort.c

    r434 r435  
    265265
    266266    get_cycle( &cycle );
    267     printf("\n[SORT] completes barrier init at cycle %d\n", (unsigned int)cycle );
     267    printf("\n[SORT] completes barrier init at cycle %d continue ?\n", (unsigned int)cycle );
     268    getchar();
    268269
    269270    // Array to sort initialization
Note: See TracChangeset for help on using the changeset viewer.