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 process used to know whether a local process is
27 waiting for a communication on a channel */
31 /********************************* Task **************************************/
33 typedef struct simdata_task {
34 smx_action_t compute; /* SURF modeling of computation */
35 smx_action_t comm; /* SURF modeling of communication */
36 double message_size; /* Data size */
37 double computation_amount; /* Computation size */
45 /******* Parallel Tasks Only !!!! *******/
47 void * *host_list; /* SURF modeling */
52 /******************************* Process *************************************/
54 typedef struct simdata_process {
55 m_host_t host; /* the host on which the process is running */
56 smx_process_t smx_process;
57 int PID; /* used for debugging purposes */
58 int PPID; /* The parent PID */
59 //m_task_t waiting_task;
62 m_host_t put_host; /* used for debugging purposes */
63 m_channel_t put_channel; /* used for debugging purposes */
64 int argc; /* arguments number if any */
65 char **argv; /* arguments table if any */
66 MSG_error_t last_errno; /* the last value returned by a MSG_function */
67 } s_simdata_process_t;
69 typedef struct process_arg {
71 m_process_code_t code;
77 } s_process_arg_t, *process_arg_t;
79 /************************** Global variables ********************************/
80 typedef struct MSG_Global {
82 xbt_fifo_t process_list;
86 } s_MSG_Global_t, *MSG_Global_t;
88 extern MSG_Global_t msg_global;
90 /*************************************************************/
92 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
93 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
94 //#define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
95 #define MSG_RETURN(val) do {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);
102 void __MSG_host_destroy(m_host_t host);
103 void __MSG_task_execute(m_process_t process, m_task_t task);
104 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task);
105 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
107 int __MSG_process_block(double max_duration, const char *info);
108 MSG_error_t __MSG_process_unblock(m_process_t process);
109 int __MSG_process_isBlocked(m_process_t process);
111 void __MSG_display_process_status(void);
113 m_process_t __MSG_process_create_with_arguments(const char *name,
114 m_process_code_t code, void *data,
115 char * hostname, int argc, char **argv);