3 /* Copyright (c) 2002-2007 Arnaud Legrand. */
4 /* Copyright (c) 2007 Bruno Donassolo. */
5 /* All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
10 #ifndef METASIMGRID_PRIVATE_H
11 #define METASIMGRID_PRIVATE_H
15 #include "simix/simix.h"
16 #include "surf/surf.h"
18 #include "xbt/dynar.h"
21 #include "xbt/context.h"
22 #include "xbt/config.h"
24 /**************** datatypes **********************************/
26 typedef struct simdata_host {
27 smx_host_t s_host; /* SURF modeling */
28 xbt_fifo_t *mbox; /* array of FIFOs used as a mailboxes */
29 smx_cond_t *sleeping; /* array of conditions on which the processes sleep if they are waiting for a communication on a channel */
30 smx_mutex_t mutex; /* mutex to access the host */
33 /********************************* Task **************************************/
35 typedef struct simdata_task {
36 smx_action_t compute; /* SURF modeling of computation */
37 smx_action_t comm; /* SURF modeling of communication */
38 double message_size; /* Data size */
39 double computation_amount; /* Computation size */
41 smx_mutex_t mutex; /* Task mutex */
48 /******* Parallel Tasks Only !!!! *******/
50 void * *host_list; /* SURF modeling */
55 /******************************* Process *************************************/
57 typedef struct simdata_process {
58 m_host_t m_host; /* the host on which the process is running */
59 smx_process_t s_process;
60 int PID; /* used for debugging purposes */
61 int PPID; /* The parent PID */
62 m_host_t put_host; /* used for debugging purposes */
63 m_channel_t put_channel; /* used for debugging purposes */
64 m_task_t waiting_task;
65 int argc; /* arguments number if any */
66 char **argv; /* arguments table if any */
67 MSG_error_t last_errno; /* the last value returned by a MSG_function */
68 } s_simdata_process_t;
70 typedef struct process_arg {
78 } s_process_arg_t, *process_arg_t;
80 /************************** Global variables ********************************/
81 typedef struct MSG_Global {
83 xbt_fifo_t process_list;
87 } s_MSG_Global_t, *MSG_Global_t;
89 extern MSG_Global_t msg_global;
91 /*************************************************************/
93 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
94 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
95 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
96 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
98 #define CHECK_HOST() xbt_assert0(SIMIX_host_get_state(SIMIX_host_self())==1,\
99 "Host failed, you cannot call this function.")
101 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
103 void __MSG_host_destroy(m_host_t host);
105 void __MSG_display_process_status(void);
107 void __MSG_process_cleanup(void *arg);
108 m_process_t __MSG_process_create_with_arguments(const char *name,
109 xbt_main_func_t code, void *data,
110 char * hostname, int argc, char **argv);