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 METASIMGRID_PRIVATE_H
9 #define METASIMGRID_PRIVATE_H
13 #include "simix/simix.h"
15 #include "xbt/dynar.h"
18 #include "xbt/context.h"
19 #include "xbt/config.h"
21 /**************** datatypes **********************************/
23 typedef struct simdata_host {
24 smx_host_t host; /* SURF modeling */
25 xbt_fifo_t *mbox; /* array of FIFOs used as a mailboxes */
26 smx_cond_t *sleeping; /* array of conditions on which the processes sleep if they are waiting for a communication on a channel */
27 smx_mutex_t mutex; /* mutex to access the host */
30 /********************************* Task **************************************/
32 typedef struct simdata_task {
33 smx_action_t compute; /* SURF modeling of computation */
34 smx_action_t comm; /* SURF modeling of communication */
35 double message_size; /* Data size */
36 double computation_amount; /* Computation size */
38 smx_mutex_t mutex; /* Task mutex */
44 /******* Parallel Tasks Only !!!! *******/
46 void * *host_list; /* SURF modeling */
51 /******************************* Process *************************************/
53 typedef struct simdata_process {
54 m_host_t host; /* the host on which the process is running */
55 smx_process_t smx_process;
56 int PID; /* used for debugging purposes */
57 int PPID; /* The parent PID */
58 m_host_t put_host; /* used for debugging purposes */
59 m_channel_t put_channel; /* used for debugging purposes */
60 int argc; /* arguments number if any */
61 char **argv; /* arguments table if any */
62 MSG_error_t last_errno; /* the last value returned by a MSG_function */
63 } s_simdata_process_t;
65 typedef struct process_arg {
67 m_process_code_t code;
73 } s_process_arg_t, *process_arg_t;
75 /************************** Global variables ********************************/
76 typedef struct MSG_Global {
78 xbt_fifo_t process_list;
82 } s_MSG_Global_t, *MSG_Global_t;
84 extern MSG_Global_t msg_global;
86 /*************************************************************/
88 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
89 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
90 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
91 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
93 #define CHECK_HOST() xbt_assert0(SIMIX_host_get_state(SIMIX_host_self())==1,\
94 "Host failed, you cannot call this function.")
96 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
98 void __MSG_host_destroy(m_host_t host);
100 void __MSG_display_process_status(void);
102 m_process_t __MSG_process_create_with_arguments(const char *name,
103 m_process_code_t code, void *data,
104 char * hostname, int argc, char **argv);