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
12 #include "surf/surf.h"
14 #include "xbt/dynar.h"
17 #include "xbt/context.h"
19 /**************** datatypes **********************************/
26 typedef struct sim_data_host {
27 void *host; /* SURF modeling */
28 xbt_fifo_t *mbox; /* array of FIFOs used as a mailboxes */
29 m_process_t *sleeping; /* array of process used to know whether a local process is
30 waiting for a communication on a channel */
32 s_xbt_swag_t process_list;
35 /********************************* Task **************************************/
37 typedef struct sim_data_task {
38 surf_action_t compute; /* SURF modeling of computation */
39 surf_action_t comm; /* SURF modeling of communication */
40 double message_size; /* Data size */
41 double computation_amount; /* Computation size */
42 xbt_dynar_t sleeping; /* process to wake-up */
45 /******************************* Process *************************************/
47 typedef struct sim_data_process {
48 s_xbt_swag_hookup_t host_hookup; /* link to other process running on the same location */
49 m_host_t host; /* the host on which the process is running */
50 xbt_context_t context; /* the context that executes the scheduler fonction */
51 int PID; /* used for debugging purposes */
52 int PPID; /* The parent PID */
53 m_task_t waiting_task; /* used for debugging purposes */
54 m_host_t put_host; /* used for debugging purposes */
55 int put_channel; /* used for debugging purposes */
56 int argc; /* arguments number if any */
57 char **argv; /* arguments table if any */
58 MSG_error_t last_errno; /* the last value returned by a MSG_function */
59 } s_sim_data_process_t;
61 /************************** Global variables ********************************/
62 typedef struct MSG_Global {
65 xbt_fifo_t process_to_run;
68 m_process_t current_process;
69 xbt_dict_t registered_functions;
70 } s_MSG_global_t, *MSG_Global_t;
72 extern MSG_Global_t msg_global;
74 /*************************************************************/
76 #define PROCESS_SET_ERRNO(val) (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno=val)
77 #define PROCESS_GET_ERRNO() (((sim_data_process_t)(MSG_process_self()->simdata))->last_errno)
78 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
79 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
81 #define CHECK_HOST() ASSERT((((sim_data_host_t) MSG_host_self()->simdata)->state==HOST_ALIVE),"Host failed, you cannot call this function.")
83 m_host_t __MSG_host_create(const char *name, void *workstation,
85 void __MSG_host_destroy(m_host_t host);
86 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);