3 /* Copyright (c) 2007 Arnaud Legrand, Bruno Donnassolo.
4 All rights reserved. */
6 /* This program is free software; you can redistribute it and/or modify it
7 * under the terms of the license (GNU LGPL) which comes with this package. */
9 #ifndef SIMIX_PRIVATE_H
10 #define SIMIX_PRIVATE_H
12 #include "simix/simix.h"
13 #include "surf/surf.h"
15 #include "xbt/dynar.h"
18 #include "xbt/context.h"
19 #include "xbt/config.h"
21 /**************** datatypes **********************************/
23 typedef struct s_simdata_host {
24 void *host; /* SURF modeling */
25 xbt_swag_t process_list;
28 /********************************* Simix Global ******************************/
30 typedef struct SIMIX_Global {
32 xbt_swag_t process_to_run;
33 xbt_swag_t process_list;
34 /* xbt_swag_t process_sleeping; */
36 smx_process_t current_process;
37 xbt_dict_t registered_functions;
40 } s_SIMIX_Global_t, *SIMIX_Global_t;
42 extern SIMIX_Global_t simix_global;
44 /******************************* Process *************************************/
46 typedef struct s_simdata_process {
47 smx_host_t host; /* the host on which the process is running */
48 xbt_context_t context; /* the context that executes the scheduler fonction */
51 smx_host_t put_host; /* used for debugging purposes */
52 int argc; /* arguments number if any */
53 char **argv; /* arguments table if any */
54 SIMIX_error_t last_errno; /* the last value returned by a MSG_function */
55 // int paje_state; /* the number of states stacked with Paje */
56 } s_simdata_process_t;
58 typedef struct process_arg {
60 smx_process_code_t code;
66 } s_process_arg_t, *process_arg_t;
68 /********************************* Mutex and Conditional ****************************/
70 typedef struct s_smx_mutex {
76 typedef struct s_smx_cond {
77 s_smx_mutex_t * mutex;
78 xbt_swag_t sleeping; //process
81 /********************************* Action **************************************/
83 typedef struct s_simdata_action {
84 surf_action_t surf_action; /* SURF modeling of computation */
86 xbt_fifo_t cond_list; /* conditional variables that must be signaled when the action finish. */
94 /******* Parallel Tasks Only !!!! *******/
97 void * *host_list; *//* SURF modeling */
102 } s_simdata_action_t;
106 /******************************* Configuration support **********************************/
108 void simix_config_init(void); /* create the config set, call this before use! */
109 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
110 extern int _simix_init_status; /* 0: beginning of time;
111 1: pre-inited (cfg_set created);
112 2: inited (running) */
113 extern xbt_cfg_t _simix_cfg_set;
120 #define PROCESS_SET_ERRNO(val) (SIMIX_process_self()->simdata->last_errno=val)
121 #define PROCESS_GET_ERRNO() (SIMIX_process_self()->simdata->last_errno)
122 #define SIMIX_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
123 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
125 #define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
126 get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
127 "Host failed, you cannot call this function.")
129 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
130 void __SIMIX_host_destroy(smx_host_t host);
132 int __SIMIX_process_block(double max_duration, const char *info);
133 SIMIX_error_t __SIMIX_process_unblock(smx_process_t process);
134 int __SIMIX_process_isBlocked(smx_process_t process);
136 void __SIMIX_display_process_status(void);
139 void __MSG_task_execute(smx_process_t process, m_task_t task);
140 MSG_error_t __MSG_wait_for_computation(smx_process_t process, m_task_t task);
141 MSG_error_t __MSG_task_wait_event(smx_process_t process, m_task_t task);