Changeset 173


Ignore:
Timestamp:
Jul 11, 2017, 10:39:51 AM (7 years ago)
Author:
max@…
Message:

style

File:
1 edited

Legend:

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

    r101 r173  
    11/*
    22 * process.h - process related management functions
    3  * 
     3 *
    44 * Authors  Ghassan Almaless (2008,2009,2010,2011,2012)
    55 *          Mohamed Lamine Karaoui (2015)
     
    8989 * 3) the <fd_array>, containing extended pointers on the open file descriptors, is only
    9090 *    complete in the reference process cluster, other copies are read-only caches.
    91  * 4) The <sem_root>, <mutex_root>, <barrier_root>, <condvar_root>, and the associated 
     91 * 4) The <sem_root>, <mutex_root>, <barrier_root>, <condvar_root>, and the associated
    9292 *    <sync_lock>, that are dynamically allocated, are only defined in the reference cluster.
    9393 * 5) The <children_root>, and <children_nr> fields are only defined in the reference
     
    9595 * 6) The <brothers_list>, <local_list>, <copies_list>, <th_tbl>, <th_nr>, <th_lock> fields
    9696 *    are defined in all process descriptors copies.
    97  * 7) The <sig_mgr> field is only defined in the reference cluster. TODO 
     97 * 7) The <sig_mgr> field is only defined in the reference cluster. TODO
    9898 ********************************************************************************************/
    9999
     
    104104        fd_array_t        fd_array;         /*! embedded open file descriptors array            */
    105105
    106         xptr_t            vfs_root_xp;      /*! extende pointer on current VFS root inode       */
     106        xptr_t            vfs_root_xp;      /*! extended pointer on current VFS root inode      */
    107107        xptr_t            vfs_bin_xp;       /*! extended pointer on .elf file inode             */
    108108        pid_t             pid;              /*! process identifier                              */
     
    112112        xptr_t            vfs_cwd_xp;       /*! extended pointer on current working dir inode   */
    113113        remote_rwlock_t   cwd_lock;         /*! lock protecting working directory changes       */
    114  
     114
    115115        xlist_entry_t     children_root;    /*! root of the children process xlist              */
    116116    uint32_t          children_nr;      /*! number of children processes                    */
     
    160160/***************   Process Descriptor Operations    *****************************************/
    161161
    162 /********************************************************************************************* 
    163  * This function allocates memory in local cluster for a process descriptor. 
    164  ********************************************************************************************* 
     162/*********************************************************************************************
     163 * This function allocates memory in local cluster for a process descriptor.
     164 *********************************************************************************************
    165165 * @ returns pointer on process descriptor if success / return NULL if failure
    166166 ********************************************************************************************/
    167167process_t * process_alloc();
    168168
    169 /********************************************************************************************* 
    170  * This function releases memory in local cluster for a process descriptor. 
    171  ********************************************************************************************* 
     169/*********************************************************************************************
     170 * This function releases memory in local cluster for a process descriptor.
     171 *********************************************************************************************
    172172 * @ process      : pointer on process descriptor to release.
    173173 ********************************************************************************************/
    174174void process_free( process_t * process );
    175175
    176 /********************************************************************************************* 
    177  * This function allocates memory and initialises the "process_init" descriptor and the
     176/*********************************************************************************************
     177 * This function allocates memory and initializes the "process_init" descriptor and the
    178178 * associated "thread_init" descriptor. It should be called once at the end of the kernel
    179179 * initialisation procedure, by the kernel "process_zero".
    180  * The "process_init" is the first user process, and all other user process will be forked
     180 * The "process_init" is the first user process, and all other user processes will be forked
    181181 * from this process. The code executed by "process_init" is stored in a .elf file, whose
    182  * pathname is defined by the CONFIG_PROCESS_INIT_PATH argument. It use fork/exec syscalls
     182 * pathname is defined by the CONFIG_PROCESS_INIT_PATH argument. It uses fork/exec syscalls
    183183 * to create the "shell" user process, and various other user daemon processes.
    184  * Practically, it build the exec_info structure, register the stdin / stdout / stderr
    185  * pseudo-file descriptors and the vfs_root and vfs_cwd in parent process_zero, and call
     184 * Practically, it builds the exec_info structure, registers the stdin / stdout / stderr
     185 * pseudo-file descriptors and the vfs_root and vfs_cwd in parent process_zero, and calls
    186186 * the generic process_make_exec() function, that makes the real job.
    187  ********************************************************************************************/ 
     187 ********************************************************************************************/
    188188void process_init_create();
    189189
    190 /********************************************************************************************* 
    191  * This function intializes a new process descriptor, in the reference cluster.
     190/*********************************************************************************************
     191 * This function initializes a new process descriptor, in the reference cluster.
    192192 * The PID value must have been defined previously by the owner cluster manager.
    193  * The reference cluster can be different from the owner cluster. 
     193 * The reference cluster can be different from the owner cluster.
    194194 * It set the pid / ppid / ref_xp fields.
    195195 * It registers this process descriptor in three lists:
     
    197197 * - the local_list, rooted in the reference cluster manager.
    198198 * - the copies_list, rooted in the owner cluster manager.
    199  * It reset the embedded structures such as the VMM or the file descriptor array.
    200  ********************************************************************************************* 
     199 * It resets the embedded structures such as the VMM or the file descriptor array.
     200 *********************************************************************************************
    201201 * @ process      : [in] pointer on process descriptor to initialize.
    202202 * @ pid          : [in] process identifier defined by owner cluster.
     
    207207                             xptr_t      parent_xp );
    208208
    209 /********************************************************************************************* 
    210  * This function intializes a copy process descriptor, in the local cluster,
    211  * from informations defined in the reference remote process descriptor.
    212  ********************************************************************************************* 
     209/*********************************************************************************************
     210 * This function initializes a copy process descriptor, in the local cluster,
     211 * from information defined in the reference remote process descriptor.
     212 *********************************************************************************************
    213213 * @ process              : [in] local pointer on process descriptor to initialize.
    214214 * @ reference_process_xp : [in] extended pointer on reference process descriptor.
     
    218218                           xptr_t      reference_process_xp );
    219219
    220 /********************************************************************************************* 
     220/*********************************************************************************************
    221221 * This function releases all memory allocated for a process descriptor in the local cluster,
    222222 * including memory allocated for embedded substructures (fd_array, vmm, etc).
    223223 * The local th_tbl[] array must be empty.
    224  ********************************************************************************************* 
     224 *********************************************************************************************
    225225 * @ process     : pointer on the process descriptor.
    226226 ********************************************************************************************/
    227227void process_destroy( process_t * process );
    228228
    229 /********************************************************************************************* 
    230  * This function kills an user process in a given cluster.
     229/*********************************************************************************************
     230 * This function kills a user process in a given cluster.
    231231 * It can be directly called in the reference cluster, or it can be called through the
    232232 * PROCESS_KILL RPC.
    233233 * - In a first loop, it set the THREAD_SIG_KILL signal to all threads of process.
    234234 * - In a second loop, it wait, for each thread the reset of the THREAD_SIG_KILL signal
    235  *   by the scheduler, and completes the thread descriptor destruction. 
    236  ********************************************************************************************* 
     235 *   by the scheduler, and completes the thread descriptor destruction.
     236 *********************************************************************************************
    237237 * @ process     : pointer on the process descriptor.
    238238 ********************************************************************************************/
    239239void process_kill( process_t * process );
    240240
    241 /********************************************************************************************* 
     241/*********************************************************************************************
    242242 * This function returns a pointer on the local copy of a process identified by its PID.
    243  * If this local copy does not exist yet, it is dynamically created, from the reference 
     243 * If this local copy does not exist yet, it is dynamically created, from the reference
    244244 * process descriptor, registered in the global copies_list, and registered in the local_list.
    245245 * This function is used by the thread_user_create() function.
    246  ********************************************************************************************* 
     246 *********************************************************************************************
    247247 * @ pid     : searched process identifier.
    248248 * @ returns pointer on the local process descriptor if success / returns NULL if failure.
     
    250250process_t * process_get_local_copy( pid_t pid );
    251251
    252 /********************************************************************************************* 
     252/*********************************************************************************************
    253253 * This function allocates memory and initializes a new user process descriptor,
    254  * and the associated main thread, from informationd found in the <exec_info> structure
    255  * (defined in the process.h file), that must be build by the caller.
    256  * The new process inherit from the parent process (i) the open file descriptors, (ii) the
     254 * and the associated main thread, from information found in the <exec_info> structure
     255 * (defined in the process.h file), that must be built by the caller.
     256 * The new process inherits from the parent process (i) the open file descriptors, (ii) the
    257257 * vfs_root and the vfs_cwd inodes.
    258  * It access to the .elf file to get the size of the code and data segments, and initialize
     258 * It accesses the .elf file to get the size of the code and data segments, and initializes
    259259 * the vsegs list in the VMM.
    260260 * It is executed in the local cluster, that becomes both "owner" and "reference".
     
    262262 * - It can be called directly by the sys_exec() function in case of local exec.
    263263 * - It can be called through the rpc_process_exec_server() function in case of remote exec.
    264  ********************************************************************************************* 
     264 *********************************************************************************************
    265265 * @ exec_info   : [in]  pointer on the exec_info structure.
    266266 * @ return 0 if success / return non-zero if error.
     
    269269
    270270
    271 /********************   Signal Management Operations   **************************************/ 
    272 
    273 /********************************************************************************************* 
     271/********************   Signal Management Operations   **************************************/
     272
     273/*********************************************************************************************
    274274 * This function TODO [AG]
    275275 ********************************************************************************************/
     
    277277
    278278
    279 /********************   File Management Operations   ****************************************/ 
    280 
    281 /*********************************************************************************************
    282  * This function initialises all entries of the local fd_array as empty.
    283  ********************************************************************************************* 
     279/********************   File Management Operations   ****************************************/
     280
     281/*********************************************************************************************
     282 * This function initializes all entries of the local fd_array as empty.
     283 *********************************************************************************************
    284284 * @ process  : pointer on the local process descriptor.
    285285 ********************************************************************************************/
     
    289289 * This function uses as many remote accesses as required, to reset an entry in fd_array[],
    290290 * in all clusters containing a copy. The entry is identified by the <file_id> argument.
    291  * This function must be executed by a thread running reference cluster, that contain
     291 * This function must be executed by a thread running reference cluster, that contains
    292292 * the complete list of process descriptors copies.
    293  ********************************************************************************************* 
     293 *********************************************************************************************
    294294 * @ process  : pointer on the local process descriptor.
    295295 * @ file_id  : file descriptor index in the fd_array.
     
    299299
    300300/*********************************************************************************************
    301  * This function returns an extended pointer on a file descriptor identified by its index 
     301 * This function returns an extended pointer on a file descriptor identified by its index
    302302 * in fd_array. It can be called by any thread running in any cluster.
    303  * It access first the local process descriptor. In case of local miss, it uses remote access
    304  * to access the reference process descriptor.
    305  * It updates the local fd_array when the file descriptor exist in reference cluster.
     303 * It accesses first the local process descriptor. In case of local miss, it uses remote
     304 * access to access the reference process descriptor.
     305 * It updates the local fd_array when the file descriptor exists in reference cluster.
    306306 * The file descriptor refcount is not incremented.
    307  ********************************************************************************************* 
     307 *********************************************************************************************
    308308 * @ process  : pointer on the local process descriptor.
    309309 * @ file_id  : file descriptor index in the fd_array.
     
    314314
    315315/*********************************************************************************************
    316  * This function checks the number of open files for a given process. 
     316 * This function checks the number of open files for a given process.
    317317 * It can be called by any thread in any cluster, because it uses portable remote access
    318318 * primitives to access the reference process descriptor.
    319  ********************************************************************************************* 
     319 *********************************************************************************************
    320320 * @ returns true if file descriptor array full.
    321321 ********************************************************************************************/
     
    327327 * It can be called by any thread in any cluster, because it uses portable remote access
    328328 * primitives to access the reference process descriptor.
    329  ********************************************************************************************* 
     329 *********************************************************************************************
    330330 * @ file_xp  : extended pointer on the file descriptor to be registered.
    331331 * @ file_id  : [out] buffer for fd_array slot index.
    332332 * @ return 0 if success / return EMFILE if array full.
    333333 ********************************************************************************************/
    334 error_t process_fd_register( xptr_t      file_xp, 
     334error_t process_fd_register( xptr_t      file_xp,
    335335                             uint32_t  * file_id );
    336336
     
    340340 * in another process descriptor. The calling thread can be running in any cluster.
    341341 * It takes the remote lock protecting the <src_xp> fd_array during the copy.
    342  * For each involved file descriptor, the refcount is incremented. 
    343  ********************************************************************************************* 
     342 * For each involved file descriptor, the refcount is incremented.
     343 *********************************************************************************************
    344344 * @ dst_xp   : extended pointer on the destination fd_array_t.
    345345 * @ src_xp   : extended pointer on the source fd_array_t.
     
    350350
    351351
    352 /********************   Thread Related Operations   *****************************************/ 
     352/********************   Thread Related Operations   *****************************************/
    353353
    354354/*********************************************************************************************
     
    357357 * allocates a new LTID, and registers the new thread in the th_tbl[].
    358358 * WARNING : the lock protecting the th_tbl[] must be taken by the caller.
    359  ********************************************************************************************* 
     359 *********************************************************************************************
    360360 * @ process  : pointer on the local process descriptor.
    361361 * @ thread   : pointer on new thread to be registered.
     
    370370 * This function removes a thread registration from the local process descriptor.
    371371 * WARNING : the lock protecting the th_tbl[] must be taken by the caller.
    372  ********************************************************************************************* 
     372 *********************************************************************************************
    373373 * @ thread   : local pointer on thread to be removed.
    374374 ********************************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.