1 /* Global constants used in RS.
6 #define DEBUG_DEFAULT 0
7 #define PRIV_DEBUG_DEFAULT 0
10 #define DEBUG DEBUG_DEFAULT
14 #define PRIV_DEBUG PRIV_DEBUG_DEFAULT
17 /* Space reserved for program and arguments. */
18 #define MAX_COMMAND_LEN 512 /* maximum argument string length */
19 #define MAX_SCRIPT_LEN 256 /* maximum restart script name length */
20 #define MAX_NR_ARGS 10 /* maximum number of arguments */
22 #define MAX_IPC_LIST 256 /* Max size of list for IPC target
25 #define MAX_DET_RESTART 10 /* maximum number of detached restarts. */
28 #define RS_IN_USE 0x001 /* set when process slot is in use */
29 #define RS_EXITING 0x002 /* set when exit is expected */
30 #define RS_REFRESHING 0x004 /* set when refresh must be done */
31 #define RS_NOPINGREPLY 0x008 /* service failed to reply to a ping request */
32 #define RS_TERMINATED 0x010 /* service has terminated */
33 #define RS_LATEREPLY 0x020 /* no reply sent to RS_DOWN caller yet */
34 #define RS_INITIALIZING 0x040 /* set when init is in progress */
35 #define RS_UPDATING 0x080 /* set when update is in progress */
36 #define RS_PREPARE_DONE 0x100 /* set when updating and preparation is done */
37 #define RS_INIT_DONE 0x200 /* set when updating and init is done */
38 #define RS_INIT_PENDING 0x400 /* set when updating and init is pending */
39 #define RS_ACTIVE 0x800 /* set for the active instance of a service */
40 #define RS_DEAD 0x1000 /* set for an instance ready to be cleaned up */
41 #define RS_CLEANUP_DETACH 0x2000 /* detach at cleanup time */
42 #define RS_CLEANUP_SCRIPT 0x4000 /* run script at cleanup time */
43 #define RS_REINCARNATE 0x8000 /* after exit, restart with a new endpoint */
45 #define RS_SRV_IS_IDLE(S) (((S)->r_flags & RS_DEAD) || ((S)->r_flags & ~(RS_IN_USE|RS_ACTIVE|RS_CLEANUP_DETACH|RS_CLEANUP_SCRIPT)) == 0)
47 /* Constants determining RS period and binary exponential backoff. */
48 #define RS_INIT_T (system_hz * 10) /* allow T ticks for init */
49 #define RS_DELTA_T (system_hz) /* check every T ticks */
50 #define BACKOFF_BITS (sizeof(long)*8) /* bits in backoff field */
51 #define MAX_BACKOFF 30 /* max backoff in RS_DELTA_T */
53 /* Magic process table addresses. */
54 #define BEG_RPROC_ADDR (&rproc[0])
55 #define END_RPROC_ADDR (&rproc[NR_SYS_PROCS])
57 /* Constants for live update. */
58 #define RS_DEFAULT_PREPARE_MAXTIME 2*RS_DELTA_T /* default prepare max time */
60 /* Definitions for boot info tables. */
61 #define NULL_BOOT_NR NR_BOOT_PROCS /* marks a null boot entry */
62 #define DEFAULT_BOOT_NR NR_BOOT_PROCS /* marks the default boot entry */
64 /* Define sys flags for the various process types. */
65 #define SRV_SF (SF_CORE_SRV) /* system services */
66 #define SRVR_SF (SRV_SF | SF_NEED_REPL) /* services needing a replica */
67 #define DSRV_SF (0) /* dynamic system services */
68 #define VM_SF (SRVR_SF) /* vm */
71 #define SRV_OR_USR(rp, X, Y) (rp->r_priv.s_flags & SYS_PROC ? X : Y)
74 #define RS_DONTREPLY 0
82 /* Configuration constants */
83 #define RS_VM_DEFAULT_MAP_PREALLOC_LEN (1024*1024*8)
84 #define RS_USE_PAGING 0
87 #define RUPDATE_INIT() memset(&rupdate, 0, sizeof(rupdate))
88 #define RUPDATE_CLEAR() RUPDATE_INIT()
90 /* Note that we have 'B' last in order to allow 'continue' statements */
91 #define RUPDATE_ITER(HEAD, RPUPD_PREV, RPUPD, B) do { \
92 for(RPUPD = HEAD, RPUPD_PREV = NULL; RPUPD != NULL; \
93 RPUPD_PREV = RPUPD, RPUPD = RPUPD->next_rpupd) { \
97 #define RUPDATE_REV_ITER(TAIL, RPUPD_PREV, RPUPD, B) do { \
99 for(RPUPD = TAIL; RPUPD != NULL; RPUPD = RPUPD->prev_rpupd) { \
100 RPUPD_PREV = RPUPD->prev_rpupd; \
105 #define RUPDATE_IS_UPDATING() (rupdate.flags & RS_UPDATING)
106 #define RUPDATE_IS_VM_UPDATING() ((rupdate.flags & RS_UPDATING) && rupdate.vm_rpupd)
107 #define RUPDATE_IS_VM_INIT_DONE() (rproc_ptr[_ENDPOINT_P(VM_PROC_NR)]->r_flags & RS_INIT_DONE)
108 #define RUPDATE_IS_RS_UPDATING() ((rupdate.flags & RS_UPDATING) && rupdate.rs_rpupd)
109 #define RUPDATE_IS_RS_INIT_DONE() (rproc_ptr[_ENDPOINT_P(RS_PROC_NR)]->r_flags & RS_INIT_DONE)
110 #define RUPDATE_IS_INITIALIZING() (rupdate.flags & RS_INITIALIZING)
111 #define RUPDATE_IS_UPD_SCHEDULED() (rupdate.num_rpupds > 0 && !RUPDATE_IS_UPDATING())
112 #define RUPDATE_IS_UPD_MULTI() (rupdate.num_rpupds > 1)
113 #define RUPDATE_IS_UPD_VM_MULTI() (rupdate.vm_rpupd && RUPDATE_IS_UPD_MULTI())
114 #define SRV_IS_UPDATING(RP) ((RP)->r_flags & RS_UPDATING)
115 #define SRV_IS_UPDATING_AND_INITIALIZING(RP) (((RP)->r_flags & (RS_UPDATING|RS_INITIALIZING)) == (RS_UPDATING|RS_INITIALIZING))
116 #define UPD_INIT_MAXTIME(RPUPD) ((RPUPD)->prepare_maxtime != RS_DEFAULT_PREPARE_MAXTIME ? (RPUPD)->prepare_maxtime : RS_INIT_T)
117 #define UPD_IS_PREPARING_ONLY(RPUPD) ((RPUPD)->lu_flags & SEF_LU_PREPARE_ONLY)
118 #define SRV_IS_PREPARING_ONLY(RP) ((RP)->r_upd.rp && UPD_IS_PREPARING_ONLY(&(RP)->r_upd))
119 #define UPD_IS_UPD_SCHEDULED(RPUPD) (RUPDATE_IS_UPD_SCHEDULED() && (RPUPD)->rp)
120 #define SRV_IS_UPD_SCHEDULED(RP) UPD_IS_UPD_SCHEDULED(&(RP)->r_upd)
122 #endif /* RS_CONST_H */