Ignore:
Timestamp:
Apr 10, 2019, 10:09:39 AM (5 years ago)
Author:
alain
Message:

Fix a bug in the vmm_remove_vseg() function: the physical pages
associated to an user DATA vseg were released to the kernel when
the target process descriptor was in the reference cluster.
This physical pages release should be done only when the page
forks counter value is zero.
All other modifications are cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/process.h

    r623 r625  
    228228
    229229/*********************************************************************************************
    230  * This function initializes a reference, user process descriptor from another process
     230 * This function initializes a reference user process descriptor from another process
    231231 * descriptor, defined by the <parent_xp> argument. The <process> and <pid> arguments
    232232 * are previously allocated by the caller. This function can be called by two functions:
    233  * 1) process_init_create() : process is the INIT process; parent is process-zero.
     233 * 1) process_init_create() : process is the INIT process, and parent is process-zero.
    234234 * 2) process_make_fork() : the parent process descriptor is generally remote.
    235235 * The following fields are initialised :
    236236 * - It set the pid / ppid / ref_xp / parent_xp / state fields.
    237  * - It initializes the VMM (register the kentry, args, envs vsegs in VSL)
     237 * - It creates an empty GPT and an empty VSL.
     238 * - It initializes the locks protecting the GPT and the VSL.
     239 * - It registers the "kernel" vsegs in VSL, using the hal_vmm_kernel_update() function.
     240 * - It registers the "args" and "envs" vsegs in VSL, using the vmm_user_init() function.
     241 * - The "code and "data" must be registered later, using the elf_load_process() function.
    238242 * - It initializes the FDT, defining the three pseudo files STDIN / STDOUT / STDERR.
    239243 *   . if INIT process     => link to kernel TXT[0].
    240  *   . if KSH[i] process   => allocate a free TXT[i] and give TXT ownership.
    241  *   . if USER process     => same TXT[i] as parent process and give TXT ownership.
     244 *   . if KSH[i] process   => allocate a free TXT[i].
     245 *   . if USER process     => link to parent process TXT[i].
    242246 * - It set the root_xp, bin_xp, cwd_xp fields.
    243247 * - It reset the children list as empty, but does NOT register it in parent children list.
     
    251255 * @ pid          : [in] process identifier.
    252256 * @ parent_xp    : [in] extended pointer on parent process descriptor.
    253  ********************************************************************************************/
    254 void process_reference_init( process_t * process,
    255                              pid_t       pid,
    256                              xptr_t      parent_xp );
     257 * @ return 0 if success / return -1 if failure
     258 ********************************************************************************************/
     259error_t process_reference_init( process_t * process,
     260                                pid_t       pid,
     261                                xptr_t      parent_xp );
    257262
    258263/*********************************************************************************************
    259264 * This function initializes a copy process descriptor, in the local cluster,
    260265 * from information defined in the reference remote process descriptor.
     266 * As the VSL and the GPT of a process copy are handled as local caches, the GPT copy is
     267 * created empty, and the VSL copy contains only the "kernel", "args", and "envs" vsegs.
    261268 *********************************************************************************************
    262269 * @ process              : [in] local pointer on process descriptor to initialize.
    263270 * @ reference_process_xp : [in] extended pointer on reference process descriptor.
    264  * @ return 0 if success / return ENOMEM if failure
     271 * @ return 0 if success / return -1 if failure
    265272 ********************************************************************************************/
    266273error_t process_copy_init( process_t * local_process,
     
    272279 * The local th_tbl[] array must be empty.
    273280 *********************************************************************************************
    274  * @ process     : pointer on the process descriptor.
     281 * @ process     : [in] pointer on the process descriptor.
    275282 ********************************************************************************************/
    276283void process_destroy( process_t * process );
     
    283290 * taken by the caller function.
    284291 *********************************************************************************************
    285  * @ process_xp : extended pointer on process descriptor.
     292 * @ process_xp    : [in] extended pointer on process descriptor.
    286293 ********************************************************************************************/
    287294void process_display( xptr_t process_xp );
     
    396403/*********************************************************************************************
    397404 * This function implements the "fork" system call, and is called by the sys_fork() function,
    398  * likely throuch the RPC_PROCESS_MAKE_FORK.
    399  * It allocates memory and initializes a new "child" process descriptor, and the associated
    400  * "child" thread descriptor in local cluster. It involves up to three different clusters :
     405 * likely through the RPC_PROCESS_MAKE_FORK.
     406 * It allocates memory and initializes a new child process descriptor, and the associated
     407 * child thread descriptor in local cluster. It involves up to three different clusters:
    401408 * - the child (local) cluster can be any cluster selected by the sys_fork function.
    402409 * - the parent cluster must be the reference cluster for the parent process.
    403410 * - the client cluster containing the thread requesting the fork can be any cluster.
    404  * The new "child" process descriptor is initialised from informations found in the "parent"
     411 * The new child process descriptor is initialised from informations found in the parent
    405412 * reference process descriptor, containing the complete process description.
    406  * The new "child" thread descriptor is initialised from informations found in the "parent"
     413 * The new child thread descriptor is initialised from informations found in the parent
    407414 * thread descriptor.
    408415 *********************************************************************************************
     
    504511
    505512/*********************************************************************************************
    506  * This function atomically registers a new thread in the local process descriptor.
    507  * It checks that there is an available slot in the local th_tbl[] array, and allocates
    508  * a new LTID using the relevant lock depending on the kernel/user type.
    509  *********************************************************************************************
    510  * @ process  : pointer on the local process descriptor.
    511  * @ thread   : pointer on new thread to be registered.
     513 * This function atomically registers a new thread identified by the <thread> argument
     514 * in the th_tbl[] array of the local process descriptor identified by the <process>
     515 * argument. It checks that there is an available slot in the local th_tbl[] array,
     516 * and allocates a new LTID using the relevant lock depending on the kernel/user type,
     517 * and returns the global thread identifier in the <trdid> buffer.
     518 *********************************************************************************************
     519 * @ process  : [in]  pointer on the local process descriptor.
     520 * @ thread   : [in]  pointer on new thread to be registered.
    512521 * @ trdid    : [out] buffer for allocated trdid.
    513522 * @ returns 0 if success / returns non zero if no slot available.
     
    516525                                 struct thread_s * thread,
    517526                                 trdid_t         * trdid );
     527
     528/*********************************************************************************************
     529 * This function atomically removes a thread identified by the <thread> argument from
     530 * the local process descriptor th_tbl[] array, and returns the number of thread currently
     531 * registered in th_tbl[] array before this remove.
     532 *********************************************************************************************
     533 * @ thread   : pointer on thread to be removed.
     534 * @ returns number of threads registered in th_tbl before thread remove.
     535 ********************************************************************************************/
     536uint32_t process_remove_thread( struct thread_s * thread );
    518537
    519538
     
    556575
    557576/*********************************************************************************************
    558  * This function gives a process identified by the <process_xp> argument the exclusive
     577 * This function gives a process identified by the <process_xp> argument the
    559578 * ownership of its attached TXT_RX terminal (i.e. put the process in foreground).
    560  * It can be called by a thread running in any cluster, but the <process_xp> must be the
    561  * owner cluster process descriptor.
     579 * It can be called by a thread running in any cluster, but the target process descriptor
     580 * must be the process owner.
    562581 *********************************************************************************************
    563582 * @ owner_xp  : extended pointer on process descriptor in owner cluster.
     
    566585
    567586/*********************************************************************************************
    568  * When the process identified by the <owner_xp> argument has the exclusive ownership of
    569  * the TXT_RX terminal, this function transfer this ownership to another attached process.
    570  * The process descriptor must be the process owner.
    571  * This function does nothing if the process identified by the <process_xp> is not
    572  * the TXT owner.
     587 * When the target process identified by the <owner_xp> argument has the exclusive ownership
     588 * of the TXT_RX terminal, this function transfer this ownership to another process attached
     589 * to the same terminal. The target process descriptor must be the process owner.
     590 * This function does nothing if the target process is not the TXT owner.
    573591 * - If the current owner is not the KSH process, the new owner is the KSH process.
    574592 * - If the current owner is the KSH process, the new owner is another attached process.
Note: See TracChangeset for help on using the changeset viewer.