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"
17 #include "xbt/context.h"
18 #include "xbt/config.h"
20 /******************************* Datatypes **********************************/
23 /********************************** Host ************************************/
25 typedef struct s_smx_simdata_host {
26 void *host; /* SURF modeling */
27 xbt_swag_t process_list;
28 } s_smx_simdata_host_t;
30 /********************************* Simix Global ******************************/
32 typedef struct SIMIX_Global {
34 xbt_swag_t process_to_run;
35 xbt_swag_t process_list;
37 smx_process_t current_process;
38 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_smx_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_mutex_t mutex; /* mutex on which the process is blocked */
51 smx_cond_t cond; /* cond on which the process is blocked */
52 int argc; /* arguments number if any */
53 char **argv; /* arguments table if any */
54 } s_smx_simdata_process_t;
56 typedef struct process_arg {
58 smx_process_code_t code;
64 } s_process_arg_t, *process_arg_t;
66 /********************************* Mutex and Conditional ****************************/
68 typedef struct s_smx_mutex {
69 xbt_swag_t sleeping; /* list of sleeping process */
74 typedef struct s_smx_cond {
75 xbt_swag_t sleeping; /* list of sleeping process */
77 xbt_fifo_t actions; /* list of actions */
81 /********************************* Action **************************************/
83 typedef struct s_smx_simdata_action {
84 surf_action_t surf_action; /* SURF modeling of computation */
88 } s_smx_simdata_action_t;
92 /******************************* Configuration support **********************************/
94 void simix_config_init(void); /* create the config set, call this before use! */
95 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
96 extern int _simix_init_status; /* 0: beginning of time;
97 1: pre-inited (cfg_set created);
98 2: inited (running) */
99 extern xbt_cfg_t _simix_cfg_set;
102 #define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
103 get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
104 "Host failed, you cannot call this function.")
106 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
107 void __SIMIX_host_destroy(smx_host_t host);
109 void __SIMIX_cond_wait(smx_cond_t cond);
111 void __SIMIX_display_process_status(void);