1/** 2 * \file 3 * \brief Startup code for distributed services 4 */ 5 6/* 7 * Copyright (c) 2010-2011, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef __START_H__ 16#define __START_H__ 17 18/** 19 * \brief Main function that starts work for master and worker dispatchers. 20 * 21 * Depending on the arguments passed in d_args->master this function starts 22 * a dispatcher running as a master or a worker. As a master it spwans 23 * worker dispatchers on the given cores (d_args->cores) and then calls 24 * the externally defined run_master() function. As a worker it calls the 25 * externally defined run_worker() function. 26 * 27 * @param d_args the generic distributed service arguments passed to this 28 dispatcher. 29 * @param m_args the service-specific arguments passed to this dispatcher. 30 * @param name the name of this service. 31 * @return an exit value (main() should return this value). 32 */ 33int dist_main(struct dist_args *d_args, void *m_args, char *name); 34 35 36 37/** 38 * \brief Externally defined function to convert service-specific arguments. 39 * 40 * This function must return an array of command line arguments, representing 41 * those in m_args, that can be passed to a worker dispatcher when it is 42 * spawned by a master. 43 * 44 * @param m_args the service-specific arguments passed to this dispatcher. 45 * @param res returns a list of command line arguments (like argv). This 46 * is malloced by this function, the caller must free it. 47 * @param res_len returns the number of elements in the res list 48 * @return success or error code. 49 */ 50errval_t worker_args(void *m_args, char **res[], int *res_len); 51 52/** 53 * \brief Externally defined function providing service specific master 54 * functionality. 55 * 56 * This function is run after all the workers have been succesfully spawned. 57 * In most cases this function won't do much, since the master's main task 58 * is to spawn workers and then coordinate their startup. 59 * 60 * @param core core ID of this dispatcher. 61 * @param cores a list of the cores that the workers run on. 62 * @param cores_len the length of the list. 63 * @param m_args the service-specific arguments passed to this dispatcher. 64 * @param name the name of this service. 65 * @return success or error code. 66 */ 67errval_t run_master(coreid_t core, coreid_t *cores, int cores_len, 68 void *m_args, char *name); 69 70/** 71 * \brief Externally defined function providing service-specific worker 72 * functionality. 73 * 74 * This function is run by every worker dispatcher when it is started. 75 * This is the main service-specific entry point. In most cases this 76 * function never returns but starts an infinite dispatch loop. 77 * 78 * @param core core ID of this dispatcher. 79 * @param cores a list of the cores that the workers run on. 80 * @param cores_len the length of the list. 81 * @param m_args the service-specific arguments passed to this dispatcher. 82 * @param name the name of this service. 83 * @return success or error code. 84 */ 85errval_t run_worker(coreid_t core, coreid_t *cores, int cores_len, 86 void *m_args, char *name); 87 88 89#endif 90