Barrelfish
Functions
start.h File Reference

Startup code for distributed services. More...

Functions

int dist_main (struct dist_args *d_args, void *m_args, char *name)
 Main function that starts work for master and worker dispatchers. More...
 
errval_t worker_args (void *m_args, char **res[], int *res_len)
 Externally defined function to convert service-specific arguments. More...
 
errval_t run_master (coreid_t core, coreid_t *cores, int cores_len, void *m_args, char *name)
 Externally defined function providing service specific master functionality. More...
 
errval_t run_worker (coreid_t core, coreid_t *cores, int cores_len, void *m_args, char *name)
 Externally defined function providing service-specific worker functionality. More...
 

Detailed Description

Startup code for distributed services.

Function Documentation

int dist_main ( struct dist_args *  d_args,
void *  m_args,
char *  name 
)

Main function that starts work for master and worker dispatchers.

Depending on the arguments passed in d_args->master this function starts a dispatcher running as a master or a worker. As a master it spwans worker dispatchers on the given cores (d_args->cores) and then calls the externally defined run_master() function. As a worker it calls the externally defined run_worker() function.

Parameters
d_argsthe generic distributed service arguments passed to this dispatcher.
m_argsthe service-specific arguments passed to this dispatcher.
namethe name of this service.
Returns
an exit value (main() should return this value).
errval_t run_master ( coreid_t  core,
coreid_t *  cores,
int  cores_len,
void *  m_args,
char *  name 
)

Externally defined function providing service specific master functionality.

This function is run after all the workers have been succesfully spawned. In most cases this function won't do much, since the master's main task is to spawn workers and then coordinate their startup.

Parameters
corecore ID of this dispatcher.
coresa list of the cores that the workers run on.
cores_lenthe length of the list.
m_argsthe service-specific arguments passed to this dispatcher.
namethe name of this service.
Returns
success or error code.
errval_t run_worker ( coreid_t  core,
coreid_t *  cores,
int  cores_len,
void *  m_args,
char *  name 
)

Externally defined function providing service-specific worker functionality.

This function is run by every worker dispatcher when it is started. This is the main service-specific entry point. In most cases this function never returns but starts an infinite dispatch loop.

Parameters
corecore ID of this dispatcher.
coresa list of the cores that the workers run on.
cores_lenthe length of the list.
m_argsthe service-specific arguments passed to this dispatcher.
namethe name of this service.
Returns
success or error code.
errval_t worker_args ( void *  m_args,
char **  res[],
int *  res_len 
)

Externally defined function to convert service-specific arguments.

This function must return an array of command line arguments, representing those in m_args, that can be passed to a worker dispatcher when it is spawned by a master.

Parameters
m_argsthe service-specific arguments passed to this dispatcher.
resreturns a list of command line arguments (like argv). This is malloced by this function, the caller must free it.
res_lenreturns the number of elements in the res list
Returns
success or error code.