1 /* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef METASIMGRID_PRIVATE_H
8 #define METASIMGRID_PRIVATE_H
11 #include "simix/simix.h"
12 #include "surf/surf.h"
14 #include "xbt/dynar.h"
17 #include "xbt/config.h"
18 #include "instr/instr_private.h"
22 /**************** datatypes **********************************/
23 typedef struct simdata_host {
24 smx_host_t smx_host; /* SURF modeling */
25 msg_mailbox_t *mailboxes; /* mailboxes to store msg tasks of of the host */
28 /********************************* Task **************************************/
30 typedef struct simdata_task {
31 smx_action_t compute; /* SURF modeling of computation */
32 smx_action_t comm; /* SIMIX communication */
33 double message_size; /* Data size */
34 double computation_amount; /* Computation size */
41 int host_nb; /* ==0 if sequential task; parallel task if not */
42 /******* Parallel Tasks Only !!!! *******/
43 smx_host_t *host_list;
48 /******************************* Process *************************************/
50 typedef struct simdata_process {
51 m_host_t m_host; /* the host on which the process is running */
52 smx_process_t s_process;
53 int PID; /* used for debugging purposes */
54 int PPID; /* The parent PID */
55 m_host_t put_host; /* used for debugging purposes */
56 m_channel_t put_channel; /* used for debugging purposes */
57 smx_action_t waiting_action;
58 m_task_t waiting_task;
59 int argc; /* arguments number if any */
60 char **argv; /* arguments table if any */
61 MSG_error_t last_errno; /* the last value returned by a MSG_function */
62 } s_simdata_process_t;
64 typedef struct process_arg {
72 } s_process_arg_t, *process_arg_t;
74 /************************** Global variables ********************************/
75 typedef struct MSG_Global {
77 xbt_fifo_t process_list;
81 unsigned long int sent_msg; /* Total amount of messages sent during the simulation */
82 } s_MSG_Global_t, *MSG_Global_t;
84 /*extern MSG_Global_t msg_global;*/
85 XBT_PUBLIC_DATA(MSG_Global_t) msg_global;
88 /*************************************************************/
90 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
91 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
92 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
93 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
95 #define CHECK_HOST() xbt_assert1(SIMIX_req_host_get_state(SIMIX_host_self())==1,\
96 "Host failed, you cannot call this function. (state=%d)",SIMIX_req_host_get_state(SIMIX_host_self()))
98 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
100 void __MSG_host_destroy(m_host_t host);
102 void __MSG_display_process_status(void);
104 void __MSG_process_cleanup(smx_process_t smx_proc);
105 void *_MSG_process_create_from_SIMIX(const char *name,
106 xbt_main_func_t code, void *data,
107 char *hostname, int argc,
108 char **argv, xbt_dict_t properties);
109 void _MSG_process_kill_from_SIMIX(void *p);
111 void _MSG_action_init(void);
112 void _MSG_action_exit(void);