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
13 #include "simix/simix.h"
14 #include "surf/surf.h"
18 #include "xbt/context.h"
19 #include "xbt/config.h"
21 /******************************* Datatypes **********************************/
24 /********************************** Host ************************************/
26 typedef struct s_smx_simdata_host {
27 void *host; /* SURF modeling */
28 xbt_swag_t process_list;
29 } s_smx_simdata_host_t;
31 /********************************* Simix Global ******************************/
33 typedef struct SIMIX_Global {
35 xbt_swag_t process_to_run;
36 xbt_swag_t process_list;
38 smx_process_t current_process;
39 xbt_dict_t registered_functions;
40 void* (*create_process_function) ();
41 void* (*kill_process_function)();
42 } s_SIMIX_Global_t, *SIMIX_Global_t;
44 extern SIMIX_Global_t simix_global;
46 /******************************* Process *************************************/
48 typedef struct s_smx_simdata_process {
49 smx_host_t host; /* the host on which the process is running */
50 xbt_context_t context; /* the context that executes the scheduler fonction */
53 smx_mutex_t mutex; /* mutex on which the process is blocked */
54 smx_cond_t cond; /* cond on which the process is blocked */
55 int argc; /* arguments number if any */
56 char **argv; /* arguments table if any */
57 } s_smx_simdata_process_t;
59 typedef struct process_arg {
61 smx_process_code_t code;
67 } s_process_arg_t, *process_arg_t;
69 /********************************* Mutex and Conditional ****************************/
71 typedef struct s_smx_mutex {
72 xbt_swag_t sleeping; /* list of sleeping process */
77 typedef struct s_smx_cond {
78 xbt_swag_t sleeping; /* list of sleeping process */
80 xbt_fifo_t actions; /* list of actions */
84 /********************************* Action **************************************/
86 typedef struct s_smx_simdata_action {
87 surf_action_t surf_action; /* SURF modeling of computation */
91 } s_smx_simdata_action_t;
95 /******************************* Configuration support **********************************/
97 void simix_config_init(void); /* create the config set, call this before use! */
98 void simix_config_finalize(void); /* destroy the config set, call this at cleanup. */
99 extern int _simix_init_status; /* 0: beginning of time;
100 1: pre-inited (cfg_set created);
101 2: inited (running) */
102 extern xbt_cfg_t _simix_cfg_set;
105 #define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
106 get_state(SIMIX_host_self()->simdata->host)==SURF_CPU_ON,\
107 "Host failed, you cannot call this function.")
109 smx_host_t __SIMIX_host_create(const char *name, void *workstation, void *data);
110 void __SIMIX_host_destroy(smx_host_t host);
112 void __SIMIX_cond_wait(smx_cond_t cond);
114 void __SIMIX_display_process_status(void);