Changeset 434 for trunk


Ignore:
Timestamp:
Feb 14, 2018, 3:41:31 PM (7 years ago)
Author:
alain
Message:

blap

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.tsar

    r431 r434  
    3838# always out-of-date, need to be regenerated everytime they are called
    3939.PHONY: compile                         \
     40        hard_config.h           \
    4041                dirs                                \
    4142                list                                \
  • trunk/kernel_config.h

    r431 r434  
    3232//                              KERNEL DEBUG
    3333//
    34 //  For all these debug variables:
     34//  Each debug variable control one kernel function, or one small group of functions.
    3535//  - trace is generated only when cycle > debug_value.
    3636//  - detailed trace is enabled when (debug_value & Ox1) is non zero.
    3737////////////////////////////////////////////////////////////////////////////////////////////
    3838
    39 #define CONFIG_CHDEV_DEBUG            0
    40 #define CONFIG_CLUSTER_DEBUG          0
    41 #define CONFIG_CONTEXT_DEBUG          0
    42 #define CONFIG_CORE_DEBUG             0
    43 #define CONFIG_DEVFS_DEBUG            0
    44 #define CONFIG_DMA_DEBUG              0
    45 #define CONFIG_DQDT_DEBUG             0
    46 #define CONFIG_ELF_DEBUG              0
    47 #define CONFIG_EXEC_DEBUG             0
    48 #define CONFIG_EXCP_DEBUG             0
    4939#define CONFIG_FATFS_DEBUG            0
    5040#define CONFIG_FBF_DEBUG              0
    51 #define CONFIG_FORK_DEBUG             0
    52 #define CONFIG_GPT_DEBUG              0
    5341#define CONFIG_GRPC_DEBUG             0
    54 #define CONFIG_IDLE_DEBUG             0
    5542#define CONFIG_IOC_DEBUG              0
    5643#define CONFIG_IRQ_DEBUG              0
    57 #define CONFIG_KCM_DEBUG              0
    58 #define CONFIG_KENTRY_DEBUG           0
    5944#define CONFIG_KHM_DEBUG              0
    60 #define CONFIG_KILL_DEBUG             0
    61 #define CONFIG_KINIT_DEBUG            0
    6245#define CONFIG_KMEM_DEBUG             0
    63 #define CONFIG_LOCKS_DEBUG            0
    6446#define CONFIG_MMAP_DEBUG             0         
    6547#define CONFIG_MMC_DEBUG              0
     
    6749#define CONFIG_NIC_DEBUG              0
    6850#define CONFIG_PIC_DEBUG              0
    69 #define CONFIG_PPM_DEBUG              0
    70 #define CONFIG_PROCESS_DEBUG          0
    7151#define CONFIG_READ_DEBUG             0
    72 #define CONFIG_RPC_DEBUG              0
    73 #define CONFIG_SCHED_DEBUG            0
    74 #define CONFIG_SIGACTION_DEBUG        0
    75 #define CONFIG_SYSCALL_DEBUG          0
    76 #define CONFIG_THREAD_DEBUG           0
    77 #define CONFIG_TXT_DEBUG              0
    78 #define CONFIG_VFS_DEBUG              0
    79 #define CONFIG_VMM_DEBUG              0
    80 #define CONFIG_WRITE_DEBUG            0
     52
     53
     54#define CONFIG_DEBUG_CHDEV_REGISTER_COMMAND   3000000
     55#define CONFIG_DEBUG_CHDEV_SEQUENCIAL_SERVER  3000000
     56
     57#define CONFIG_DEBUG_CLUSTER_INIT             0
     58
     59#define CONFIG_DEBUG_DEV_TXT                  3000000
     60
     61#define CONFIG_DEBUG_DEVFS_INIT               0
     62#define CONFIG_DEBUG_DEVFS_MOVE               3000000
     63
     64#define CONFIG_DEBUG_GPT_ACCESS               0
     65
     66#define CONFIG_DEBUG_HAL_KENTRY               0
     67#define CONFIG_DEBUG_HAL_TXT                  3000000
     68#define CONFIG_DEBUG_HAL_EXCEPTIONS           0
     69
     70#define CONFIG_DEBUG_KCM_ALLOC                0
     71
     72#define CONFIG_DEBUG_KERNEL_INIT              0
     73#define CONFIG_DEBUG_KMEM_ALLOC               0
     74
     75#define CONFIG_DEBUG_LOCKS                    0
     76
     77#define CONFIG_DEBUG_PPM_ALLOC_PAGES          0
     78#define CONFIG_DEBUG_PPM_FREE_PAGES           0
     79
     80#define CONFIG_DEBUG_PROCESS_COPY_INIT        0
     81#define CONFIG_DEBUG_PROCESS_DESTROY          0
     82#define CONFIG_DEBUG_PROCESS_INIT_CREATE      0
     83#define CONFIG_DEBUG_PROCESS_MAKE_EXEC        0
     84#define CONFIG_DEBUG_PROCESS_MAKE_FORK        0
     85#define CONFIG_DEBUG_PROCESS_MAKE_KILL        0
     86#define CONFIG_DEBUG_PROCESS_REFERENCE_INIT   0
     87#define CONFIG_DEBUG_PROCESS_SIGACTION        0
     88#define CONFIG_DEBUG_PROCESS_ATTACH           0
     89#define CONFIG_DEBUG_PROCESS_DETACH           0
     90#define CONFIG_DEBUG_PROCESS_ZERO_CREATE      0
     91
     92#define CONFIG_DEBUG_RPC_MARSHALING           0
     93#define CONFIG_DEBUG_RPC_GENERIC              0
     94
     95#define CONFIG_DEBUG_SCHED_HANDLE_SIGNALS     0     
     96#define CONFIG_DEBUG_SCHED_YIELD              5000001
     97
     98#define CONFIG_DEBUG_SYSCALLS_ERROR           0
     99
     100#define CONFIG_DEBUG_SYS_DISPLAY              0
     101#define CONFIG_DEBUG_SYS_EXEC                 3000000
     102#define CONFIG_DEBUG_SYS_EXIT                 3000000
     103#define CONFIG_DEBUG_SYS_FORK                 3000000
     104#define CONFIG_DEBUG_SYS_KILL                 3000000
     105#define CONFIG_DEBUG_SYS_READ                 3000000
     106#define CONFIG_DEBUG_SYS_WAIT                 3000000
     107#define CONFIG_DEBUG_SYS_WRITE                3000000
     108
     109#define CONFIG_DEBUG_THREAD_DESTROY           0
     110#define CONFIG_DEBUG_THREAD_IDLE              0
     111#define CONFIG_DEBUG_THREAD_KERNEL_CREATE     0
     112#define CONFIG_DEBUG_THREAD_KILL              0
     113#define CONFIG_DEBUG_THREAD_USER_CREATE       0
     114#define CONFIG_DEBUG_THREAD_USER_FORK         0
     115#define CONFIG_DEBUG_THREAD_BLOCK             0
     116
     117#define CONFIG_DEBUG_VFS_INODE_CREATE         0
     118#define CONFIG_DEBUG_VFS_INODE_LOAD           0
     119#define CONFIG_DEBUG_VFS_DENTRY_CREATE        0
     120#define CONFIG_DEBUG_VFS_OPEN                 0
     121#define CONFIG_DEBUG_VFS_LOOKUP               0
     122#define CONFIG_DEBUG_VFS_ADD_CHILD            0
     123#define CONFIG_DEBUG_VFS_MAPPER_MOVE          0
     124#define CONFIG_DEBUG_VFS_MAPPER_LOAD          0
     125
     126#define CONFIG_DEBUG_VMM_CREATE_VSEG          0
     127#define CONFIG_DEBUG_VMM_DESTROY              0
     128#define CONFIG_DEBUG_VMM_FORK_COPY            0
     129#define CONFIG_DEBUG_VMM_GET_ONE_PPN          0
     130#define CONFIG_DEBUG_VMM_GET_PTE              0
     131#define CONFIG_DEBUG_VMM_INIT                 0
     132#define CONFIG_DEBUG_VMM_PAGE_ALLOCATE        0
     133#define CONFIG_DEBUG_VMM_SET_COW              0
     134#define CONFIG_DEBUG_VMM_UNMAP_VSEG           0
     135#define CONFIG_DEBUG_VMM_UPDATE_PTE           0
    81136
    82137////////////////////////////////////////////////////////////////////////////////////////////
     
    161216////////////////////////////////////////////////////////////////////////////////////////////
    162217
    163 #define CONFIG_SCHED_TICK_MS_PERIOD         5000    // number of milliseconds per period
     218#define CONFIG_SCHED_TICK_MS_PERIOD         10000   // number of milliseconds per period
    164219#define CONFIG_SCHED_TICKS_PER_QUANTUM      1       // number of ticks between scheduling
    165220#define CONFIG_SCHED_MAX_THREADS_NR         32      // max number of threads per core
  • trunk/libs/stdio.h

    r426 r434  
    264264
    265265/*****************************************************************************************
    266  * This function implements the POSIX "kill" system call.
     266 * This function implements the "kill" system call on the user side.
    267267 * It register the signal defined by the <sig_id> argument in all thread descriptors
    268268 * of a target process identified by the <pid> argument. This is done in all clusters
    269269 * containing threads for the target process.
     270 * It can be executed by any thread running in any cluster, as this function uses
     271 * remote access to traverse the list of process copies stored in the owner cluster,
     272 * and the RPC_SIGNAL_RISE to signal the remote threads.
     273 * This function does nothing for (sig_id == 0). This can be used to check process pid.
     274 * TODO : This first implementation supports only SIGKILL / SIGSTOP / SIGCONT values.
    270275 *****************************************************************************************
    271276 * @ pid      : target process identifier.
    272  * @ sig_id   : index defining the signal type (from 1 to 31).
     277 * @ sig_id   : index defining the signal type.
    273278 * @ return 0 if success / returns -1 if failure.
    274279 ****************************************************************************************/
     
    277282
    278283/*****************************************************************************************
    279  * This function implements the POSIX "getpid" system call.
     284 * This function implements the "getpid" system call on the user side.
    280285 *****************************************************************************************
    281286 * @ returns the process PID for the calling thread process.
     
    284289
    285290/*****************************************************************************************
    286  * This function implement the POSIX "fork" system call.
     291 * This function implement the "fork" system call on the user side.
    287292 * The calling process descriptor (parent process), and the associated thread descriptor
    288  * are replicated in the same cluster as the calling thread, but the new process (child
    289  * process) is registered in another target cluster, that is the new process owner.
    290  * The child process and the associated main thread will be migrated to the target cluster
    291  * later, when the child process makes an "exec" or any other system call.
     293 * are replicated in a - likely - remote cluster, that becomes the new process owner.
     294 * The child process get a new PID is linked to the parent PID. The child process inherit
     295 * from the parent process the memory image, and all open files (including the TXT).
     296 * The child process becomes the TXT terminal owner.
    292297 * The target cluster depends on the "fork_user" flag and "fork_cxy" variable that can be
    293298 * stored in the calling thread descriptor by the specific fork_place() system call.
    294299 * If not, the kernel function makes a query to the DQDT to select the target cluster.
    295300 *****************************************************************************************
    296  * @ returns child process PID if success / returns -1 if failure
     301 * @ if success, returns child process PID to parent, and return O to child.
     302 * @ if failure, returns -1 to parent / no child process is created.
    297303 ****************************************************************************************/
    298304int fork();
    299305
    300306/*****************************************************************************************
    301  * This function implement the "exec" system call.
    302  * It is executed in the client cluster, but the new process descriptor and main thread
    303  * must be created in a server cluster, that is generally another cluster.
    304  * - if the server_cluster is the client cluster, call directly the process_make_exec()
    305  *   function to create a new process, and launch a new thread in local cluster.
    306  * - if the target_cluster is remote, call rpc_process_exec_client() to execute the
    307  *   process_make_exec() on the remote cluster.
    308  * In both case this function build an exec_info_t structure containing all informations
    309  * required to build the new process descriptor and the associated thread.
    310  * Finally, the calling process and thread are deleted.
     307 * This function implement the "exec" system call on the user side.
     308 * It creates, in the same cluster as the calling thread, a new process descriptor,
     309 * and a new associated main thread descriptor, executing a new memory image defined
     310 * by the <filename> argument. This new process inherit from the old process the PID
     311 * and the PPID, as well as all open files (including the TXT).
     312 * The old process descriptor, and all its threads are blocked, and marked for deletion.
     313 * Therefore the exec syscall does not return to the calling thread in case of success.
     314 * This function build an exec_info_t structure containing the new process arguments,
     315 * as defined by the <arv> argument, and the new process environment variables,
     316 * as defined by the <envp>  argument.
     317 * TODO : the <argv> and <envp> arguments are not supported yet (both must be NULL).
    311318 *****************************************************************************************
    312319 * @ filename : string pointer on .elf filename (virtual pointer in user space)
    313320 * @ argv     : array of strings on process arguments (virtual pointers in user space)
    314321 * @ envp     : array of strings on environment variables (virtual pointers in user space)
    315  * @ returns O if success / returns -1 if failure.
     322 * @ does not return if success / returns -1 if failure.
    316323 ****************************************************************************************/
    317324int exec( char  * filename,
  • trunk/params.mk

    r401 r434  
    55Y_SIZE    = 1
    66NB_PROCS  = 1
    7 NB_TTYS   = 3
     7NB_TTYS   = 2
    88FBF_WIDTH = 128
    99IOC_TYPE  = IOC_BDV
  • trunk/user/init/init.c

    r427 r434  
    55///////////////////////////////////////////////////////////////////////////////////////
    66// This single thread application implement the "init" process for ALMOS-MKH.
    7 // - It uses the fork/exec syscalls to create N KSH child processes
    8 //   (one child process per user terminal), and register the corresponding PIDs
    9 //   in the ksh_pid[] array. Then it calls the wait() function to block.
    10 // - It is reactivated when any child KSH process is terminated by a SIGKILL signal,
    11 //   or stopped by a SIGSTOP signal. In case of SIGKILL, it scan all registered KSH
    12 //   processes and re-creates each killed KSH process, using a new fork/exec.
    13 // It includes the hard_config.h file to get the NB_TXT_CHANNELS parameter.
     7// It uses the fork/exec syscalls to create N KSH child processes
     8// (one child process per user terminal).
     9// It includes the hard_config.h file to get th NB_TXT_CHANNELS parameter.
     10//
     11// TODO : Register the PIDs for all KSH[i] in a ksh_pid[] array.
     12// Then calls the wait() function to block, and reactivate any child KSH process
     13// that has been deleted, using a new fork/exec.
    1414///////////////////////////////////////////////////////////////////////////////////////
    1515
     
    2020#include <pthread.h>
    2121
    22 #define NB_KSH  (NB_TXT_CHANNELS - 1)
    23 
     22#define DELAY_BETWEEN_FORK 100000
    2423
    2524//////////
     
    2726{
    2827    int     i;
    29     int     ret;           // fork return value 
    30     int     child_pid;
    31     int     status;        // used by the wait function
     28    int     ret_fork;      // fork return value 
     29    int     ret_exec;      // fork return value 
     30    int     received_pid;  // pid received from the wait syscall
     31    int     status;        // used by the wait syscall
    3232    char    string[64];
    3333
     
    3636
    3737    // create the KSH processes (one per user terminal)
    38     for( i = 0 ; i <  NB_KSH ; i++ )
     38    for( i = 1 ; i <  NB_TXT_CHANNELS ; i++ )
    3939    {
    40         // INIT process fork process CHILD
    41         ret = fork();
    4240
    43         if( ret < 0 )                            // error in fork
     41snprintf( string , 64 , "@@@ before fork / iter = %d\n" , i );
     42display_string( string );
     43
     44        // INIT process fork process CHILD[i]
     45        ret_fork = fork();
     46
     47snprintf( string , 64 , "@@@ after fork / iter = %d / ret_fork = %d\n" , i , ret_fork );
     48display_string( string );
     49
     50        if( ret_fork< 0 )   // error in fork
    4451        {
    45             // display error message on TXT0 terminal
    46             display_string( "init process cannot fork\n" );
    47 
    48             // INIT process exit
    49             exit( 1 );
    50         }
    51         else if( ret > 0 )                     // we are in INIT process
    52         {
    53             // INIT display string on kernel TXT0
    54             snprintf( string , 64 , "INIT created KSH[%d]\n" , i );
     52            // INIT display error message on TXT0 terminal
     53            snprintf( string , 64 , "init cannot fork child[%d]\n" , i );
    5554            display_string( string );
    5655
    57             // INIT process deschedule
    58             pthread_yield();
     56            // INIT exit
     57            exit( 0 );
    5958        }
    60         else                                   // we are in CHILD process
     59        else if( ret_fork == 0 )                    // we are in CHILD[i] process
    6160        {
    62             // CHILD process exec process KSH
    63             if ( exec( "/bin/user/ksh.elf" , NULL , NULL ) )  // CHILD failure
     61            // CHILD[i] process exec process KSH[i]
     62            ret_exec = exec( "/bin/user/ksh.elf" , NULL , NULL );
     63
     64            if ( ret_exec )   // error in exec             
    6465            {
    6566                // display error message on TXT0 terminal
    66                 display_string( "child process cannot exec process ksh\n" );
     67                snprintf( string , 64 , "child[%d] cannot exec ksh[%d]\n" , i , i );
     68                display_string( string );
    6769
    68                 // CHILD process exit
    69                 exit( 1 );
    70             }
    71             else                                             // child success
    72             {
    73                 // CHILD process deschedule
    74                 pthread_yield();
     70                // CHILD[i] exit
     71                // exit( 0 );
    7572            }
    7673        }
    77     }
     74        else                                      // we are in INIT process
     75        {
     76             // INIT display CHILD[i] process PID
     77             snprintf( string , 64 , "INIT forked CHILD[%d] / pid = %x\n", i , ret_fork );
     78             display_string( string );
    7879
     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 );
    79104// @@@
    80 display_string( "@@@  INIT process created all KSH processes\n" );
    81105display_process( 0 );
    82106display_sched( 0 , 0 );
    83107// @@@
     108        }
     109
     110    }
    84111
    85112    // This blocking loop is only for debug, because KSH[i] processes
    86     // should never be killed, and INIT should never exit the wait() function.
     113    // should never be killed, and INIT should never return from the wait() function.
    87114    while( 1 )
    88115    {
    89116        // block on child process termination
    90         child_pid = wait( &status );
     117        received_pid = wait( &status );
    91118
    92         // build a string to report unexpected KSH process termination
    93         snprintf( string , 64 , "KSH process %x unexpectedly terminated" , child_pid );
    94 
    95         // display string on kernel TXT0 (INIT has no TXT terminal)
     119        // display string to report unexpected KSH process termination
     120        snprintf( string , 64 , "KSH process %x unexpectedly terminated" , received_pid );
    96121        display_string( string );
    97122    }
  • trunk/user/ksh/ksh.c

    r427 r434  
    297297static void cmd_load( int argc , char **argv )
    298298{
    299         unsigned int         ret_pid;
    300     unsigned int         new_pid;
     299        int                  ret;
     300    unsigned int         ksh_pid;
    301301        char               * pathname;
    302302    unsigned int         background;
     
    304304        if( (argc < 2) || (argc > 3) ) 
    305305    {
    306                 printf("  usage: %s pathname [&] \n", argv[0] );
     306                printf("  usage: %s pathname [&]\n", argv[0] );
    307307                return;
    308308        }
     
    311311
    312312    if( argc == 3 ) background = (argv[2][0] == '&');
    313 
    314     // fork system call
    315         ret_pid = fork();
    316 
    317     if (ret_pid == 0)  // it is the child process
    318     {
    319         // exec system call
    320         if( exec( pathname , NULL , NULL ) )
     313    else            background = 0;
     314
     315    // get KSH process PID
     316    ksh_pid = getpid();
     317
     318    // KSH process fork CHILD process
     319        ret = fork();
     320
     321    if ( ret < 0 )      // it is a failure reported to parent
     322    {
     323        printf("  error: ksh process unable to fork\n");
     324    }
     325    else if (ret == 0)  // it is the CHILD process
     326    {
     327        // give back to KSH process the terminal ownership
     328        if( background ) fg( ksh_pid );
     329
     330        // CHILD process exec NEW process
     331        ret = exec( pathname , NULL , NULL );
     332
     333        if( ret )
    321334        {
    322335            printf("  error: new process unable to exec <%s>\n", pathname );
    323336            exit(0);
    324337        }
    325 
    326         // get new process pid
    327         new_pid = getpid();
    328 
    329         // give new process terminal ownership
    330         if( background == 0 ) fg( new_pid );
    331338        }
    332     else if ( ret_pid < 0 )  // it is a failure reported to parent
    333     {
    334         printf("  error: unable to fork\n");
    335     }
    336339}   // end cmd_load
    337340
     
    624627                if (!found)
    625628        {
    626                         printf("\n  undefined command %s\n", argv[0]);
     629                        printf("  undefined command <%s>\n", argv[0]);
    627630                }
    628631        }
  • trunk/user/pgcd/pgcd.c

    r427 r434  
    1616    int opx;
    1717    int opy;
    18     char c;
    1918
    2019    printf( "*** Starting interactive pgcd ***\n\n" );
  • trunk/user/sort/sort.c

    r427 r434  
    240240    {
    241241        printf("\n[SORT ERROR] number of cores must be power of 2\n");
    242         pthread_exit( NULL );
     242        exit( 0 );
    243243    }
    244244
     
    247247    {
    248248        printf("\n[SORT ERROR] array size must be multiple of number of threads\n");
    249         pthread_exit( NULL );
     249        exit( 0 );
    250250    }
    251251
     
    261261    {
    262262        printf("\n[SORT ERROR] cannot initialise barrier\n" );
    263         pthread_exit( NULL );
     263        exit( 0 );
    264264    }
    265265
     
    309309                    {
    310310                        printf("\n[SORT ERROR] creating thread %x\n", thread_uid );
    311                         pthread_exit( NULL );
     311                        exit( 0 );
    312312                    }
    313313         
     
    350350    {
    351351        printf("\n[SORT] success at cycle %d\n", (unsigned int)cycle );
    352         pthread_exit( NULL );
     352        exit( 0 );
    353353    }
    354354    else
    355355    {
    356356        printf("\n[SORT] failure at cycle %d\n", (unsigned int)cycle );
    357         pthread_exit( NULL );
     357        exit( 0 );
    358358    }
    359359
Note: See TracChangeset for help on using the changeset viewer.