3 /* Copyright (c) 2002,2004,2004 Arnaud Legrand. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
8 #ifndef SIMIX_PRIVATE_H
9 #define SIMIX_PRIVATE_H
11 #include "simix/simix.h"
12 #include "surf/surf.h"
14 #include "xbt/dynar.h"
17 #include "xbt/context.h"
18 #include "xbt/config.h"
20 /**************** datatypes **********************************/
22 typedef struct s_simdata_host {
23 void *host; /* SURF modeling */
24 xbt_swag_t process_list;
27 /********************************* Simix Global ******************************/
29 typedef struct SIMIX_Global {
31 xbt_swag_t process_to_run;
32 xbt_swag_t process_list;
33 /* xbt_swag_t process_sleeping; */
35 smx_process_t current_process;
36 xbt_dict_t registered_functions;
39 } s_SIMIX_Global_t, *SIMIX_Global_t;
41 extern SIMIX_Global_t simix_global;
43 /******************************* Process *************************************/
45 typedef struct s_simdata_process {
46 smx_host_t host; /* the host on which the process is running */
47 xbt_context_t context; /* the context that executes the scheduler fonction */
50 smx_host_t put_host; /* used for debugging purposes */
51 int argc; /* arguments number if any */
52 char **argv; /* arguments table if any */
53 SIMIX_error_t last_errno; /* the last value returned by a MSG_function */
54 // int paje_state; /* the number of states stacked with Paje */
55 } s_simdata_process_t;
57 typedef struct process_arg {
59 smx_process_code_t code;
65 } s_process_arg_t, *process_arg_t;
67 /********************************* Mutex and Conditional ****************************/
69 typedef struct s_smx_mutex {
75 typedef struct s_smx_cond {
76 s_smx_mutex_t * mutex;
77 xbt_swag_t sleeping; //process
80 /********************************* Action **************************************/
82 typedef struct s_simdata_action {
83 surf_action_t surf_action; /* SURF modeling of computation */
85 xbt_fifo_t cond_list; /* conditional variables that must be signaled when the action finish. */
93 /******* Parallel Tasks Only !!!! *******/
96 void * *host_list; *//* SURF modeling */
101 } s_simdata_action_t;
105 /******************************* Configuration support **********************************/
107 void simix_config_init(void); /* create the config set, call this before use! */
108 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
109 extern int _simix_init_status; /* 0: beginning of time;
110 1: pre-inited (cfg_set created);
111 2: inited (running) */
112 extern xbt_cfg_t _simix_cfg_set;
119 #define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
120 #define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
121 #define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
122 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
124 #define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
125 get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
126 "Host failed, you cannot call this function.")
128 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
129 void __SIMIX_host_destroy(smx_host_t host);
131 int __SIMIX_process_block(double max_duration, const char *info);
132 SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
133 int __SIMIX_process_isBlocked(smx_process_t process);
135 void __SIMIX_display_process_status(void);
138 void __MSG_task_execute(smx_process_t process, m_task_t task);
139 MSG_error_t __MSG_wait_for_computation(smx_process_t process, m_task_t task);
140 MSG_error_t __MSG_task_wait_event(smx_process_t process, m_task_t task);