PiP - Process-in-Process
|
the PiP library More...
Files | |
file | pip.h |
int | pip_init (int *pipidp, int *ntasks, void **root_expp, int opts) |
Initialize the PiP library. | |
int | pip_fin (void) |
finalize the PiP library. | |
int | pip_spawn (char *filename, char **argv, char **envv, int coreno, int *pipidp, pip_spawnhook_t before, pip_spawnhook_t after, void *hookarg) |
spawn a PiP task | |
int | pip_export (void *exp) |
export a memory region of the calling PiP root or a PiP task to the others. | |
int | pip_import (int pipid, void **expp) |
import the exposed memory region of the other. | |
int | pip_get_addr (int pipid, const char *symnam, void **addrp) |
import the exposed memory region of the other. | |
int | pip_get_pipid (int *pipidp) |
get PIPID | |
int | pip_get_ntasks (int *ntasksp) |
get the maximum number of the PiP tasks | |
int | pip_isa_piptask (void) |
check if the calling task is a PiP task or not | |
int | pip_get_mode (int *modep) |
get the PiP execution mode | |
int | pip_exit (int retval) |
terminate PiP task | |
int | pip_wait (int pipid, int *retval) |
wait for the termination of a PiP task | |
int | pip_trywait (int pipid, int *retval) |
wait for the termination of a PiP task in a non-blocking way | |
int | pip_kill (int pipid, int signal) |
deliver a signal to a PiP task | |
int | pip_get_id (int pipid, intptr_t *idp) |
deliver a process or thread ID | |
const char * | pip_get_mode_str (void) |
get a string of the current execution mode | |
void | pip_barrier_init (pip_barrier_t *barrp, int n) |
initialize barrier synchronization structure | |
void | pip_barrier_wait (pip_barrier_t *barrp) |
wait on barrier synchronization in a busy-wait way |
the PiP library
int pip_init | ( | int * | pipidp, |
int * | ntasks, | ||
void ** | root_expp, | ||
int | opts | ||
) |
Initialize the PiP library.
[out] | pipidp | When this is called by the PiP root process, then this returns PIP_PIPID_ROOT, otherwise it returns the PIPID of the calling PiP task. |
[in,out] | ntasks | When called by the PiP root, it specifies the maximum number of PiP tasks. When called by a PiP task, then it returns the number specified by the PiP root. |
[in,out] | root_expp | If the root PiP is ready to export a memory region to any PiP task(s), then this parameter points to the variable holding the exporting address of the root PiP. If the PiP root is not ready to export or has nothing to export then this variable can be NULL. When called by a PiP task, it returns the exporting address of the PiP root, if any. |
[in] | opts | This must be zero at the point of this writing. |
This function initializes the PiP library. The PiP root process must call this. A PiP task is not required to call this function unless the PiP task calls any PiP functions.
Is is NOT guaranteed that users can spawn tasks up to the number specified by the ntasks argument. There are some limitations come from outside of the PiP library (GLIBC).
int pip_fin | ( | void | ) |
finalize the PiP library.
This function finalize the PiP library.
int pip_spawn | ( | char * | filename, |
char ** | argv, | ||
char ** | envv, | ||
int | coreno, | ||
int * | pipidp, | ||
pip_spawnhook_t | before, | ||
pip_spawnhook_t | after, | ||
void * | hookarg | ||
) |
spawn a PiP task
[in] | filename | The executable to run as a PiP task |
[in] | argv | Argument(s) for the spawned PiP task |
[in] | envv | Environment variables for the spawned PiP task |
[in] | coreno | Core number for the PiP task to be bound to. If PIP_CPUCORE_ASIS is specified, then the core binding will not take place. |
[in,out] | pipidp | Specify PIPID of the spawned PiP task. If PIP_PIPID_ANY is specified, then the PIPID of the spawned PiP task is up to the PiP library and the assigned PIPID will be returned. |
[in] | before | Just before the executing of the spawned PiP task, this function is called so that file descriptors inherited from the PiP root, for example, can deal with. This is only effective with the PiP process mode. This function is called with the argument hookarg described below. |
[in] | after | This function is called when the PiP task terminates for the cleanup purpose. This function is called with the argument hookarg described below. |
[in] | hookarg | The argument for the before and after function call. |
This function is to spawn a PiP task. These functions are introduced to follow the programming style of conventional fork
and exec
. before function does the prologue found between the fork
and exec
. after function is to free the argument if it is malloc()ed
. Note that the before and after functions are called in the different context from the spawned PiP task. More specifically, any variables defined in the spawned PiP task cannot be accessible from the before and after functions.
int pip_export | ( | void * | exp | ) |
export a memory region of the calling PiP root or a PiP task to the others.
[in] | exp | Starting address of a memory region of the calling process or task to the others. function call. |
The PiP root or a PiP task can export a memory region only once.
int pip_import | ( | int | pipid, |
void ** | expp | ||
) |
import the exposed memory region of the other.
[in] | pipid | The PIPID to import the exposed address |
[out] | expp | The starting address of the exposed region of the PiP task specified by the pipid. |
pip_init
function call, then it is guaranteed to be imported by PiP tasks at any time.int pip_get_addr | ( | int | pipid, |
const char * | symnam, | ||
void ** | addrp | ||
) |
import the exposed memory region of the other.
[in] | pipid | The PIPID to import the exposed address |
[in] | symnam | The name of a symbol existing in the specified PiP task |
[out] | addrp | The address of the variable of the PiP task specified by the pipid. |
int pip_get_pipid | ( | int * | pipidp | ) |
get PIPID
[out] | pipidp | This parameter points to the variable which will be set to the PIPID of the calling process. |
int pip_get_ntasks | ( | int * | ntasksp | ) |
get the maximum number of the PiP tasks
[out] | ntasksp | This parameter points to the variable which will be set to the maximum number of the PiP tasks. |
int pip_isa_piptask | ( | void | ) |
check if the calling task is a PiP task or not
pip_init()
function. int pip_get_mode | ( | int * | modep | ) |
get the PiP execution mode
[out] | modep | This parameter points to the variable which will be set to the PiP execution mode |
int pip_exit | ( | int | retval | ) |
terminate PiP task
[in] | retval | Terminate PiP task with the exit number specified with this parameter. |
int pip_wait | ( | int | pipid, |
int * | retval | ||
) |
wait for the termination of a PiP task
[in] | pipid | PIPID to wait for. |
[out] | retval | Exit value of the terminated PiP task |
exit
glibc function.int pip_trywait | ( | int | pipid, |
int * | retval | ||
) |
wait for the termination of a PiP task in a non-blocking way
[in] | pipid | PIPID to wait for. |
[out] | retval | Exit value of the terminated PiP task |
int pip_kill | ( | int | pipid, |
int | signal | ||
) |
deliver a signal to a PiP task
[out] | pipid | PIPID of a target PiP task |
[out] | signal | signal number to be delivered |
int pip_get_id | ( | int | pipid, |
intptr_t * | idp | ||
) |
deliver a process or thread ID
[out] | pipid | PIPID of a target PiP task |
[out] | idp | a pointer to store the ID value |
const char* pip_get_mode_str | ( | void | ) |
get a string of the current execution mode
void pip_barrier_init | ( | pip_barrier_t * | barrp, |
int | n | ||
) |
initialize barrier synchronization structure
[in] | barrp | pointer to a PiP barrier structure |
[in] | n | number of participants of this barrier synchronization |
void pip_barrier_wait | ( | pip_barrier_t * | barrp | ) |
wait on barrier synchronization in a busy-wait way
[in] | barrp | pointer to a PiP barrier structure |