Changeset 682 for trunk/user/init/init.c


Ignore:
Timestamp:
Jan 3, 2021, 11:32:52 PM (3 years ago)
Author:
alain
Message:

Introduce three new applications:

  • windows : to test the FBF windows kernel manager
  • udp_chat : chat application based on UDP sockets.
  • tcp_chat : chat application based on TCP sockets (including packet loss recovery).
File:
1 edited

Legend:

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

    r676 r682  
    77// It uses the fork/exec syscalls to create N KSH child processes
    88// (one child process per user TXT terminal).
    9 // Then calls the wait() function to block, and recreate any child KSH process
     9// Then it calls the wait() function to block, and recreate any child KSH process
    1010// that has been deleted, using a new fork/exec.
    1111///////////////////////////////////////////////////////////////////////////////////////
     
    3131    int           status;        // used by the wait syscall
    3232    char          string[64];    // log messages on kernel TXT0
     33    unsigned int  cxy;           // target cluster identifier
    3334
    3435#if DEBUG_PROCESS_INIT
     
    3637#endif
    3738
    38     // get number of TXT channels from hard configuration
     39    // get number of TXT channels and number of clusters
    3940    hard_config_t config;     
    4041
     
    4243
    4344    unsigned int  txt_channels = config.txt_channels;
     45    unsigned int  x_size       = config.x_size;
     46    unsigned int  y_size       = config.y_size;
     47    unsigned int  n_clusters    = x_size * y_size;
    4448
    4549    // check number of TXT channels
     
    5256    }
    5357
     58    cxy = 0;
     59
    5460    // create the KSH processes (one per user terminal)
    5561    for( i = 1 ; i <  txt_channels ; i++ )
    5662    {
     63        // compute target cluster
     64        cxy = (cxy + 1) % n_clusters;
     65
     66        // select target cluster
     67        if( place_fork( cxy ) )
     68        {
     69            // INIT display error message 
     70            snprintf( string , 64 ,
     71            "\n[init ERROR] cannot place fork for child[%d] => suicide" , i );
     72            display_string( string );
     73
     74            // INIT suicide
     75            exit( EXIT_FAILURE );
     76        }
     77
     78
    5779        // INIT process fork process CHILD[i]
    5880        ret_fork = fork();
     
    94116            // INIT display CHILD[i] process PID
    95117            snprintf( string , 64 ,
    96             "\n[init] (pid 0x1) create ksh[%d] (pid %x)", i , ret_fork );
    97             display_string( string );
    98 
    99             // wait signal from KSH[i] before creating KSH[i+1]
    100             pause();
     118            "[init] (pid 0x1) create ksh[%d] (pid %x)", i , ret_fork );
     119            display_string( string );
    101120        }
    102121    }
     
    104123#if DEBUG_PROCESS_INIT
    105124{
     125    // keep blocked for 2 seconds
     126    // to allow all KSH[i] process
     127    // to be launched before display
     128
     129    sleep( 2 );
     130
    106131    unsigned int  x;             // cluster x coordinate
    107132    unsigned int  y;             // cluster y coordinate
Note: See TracChangeset for help on using the changeset viewer.