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 simdata_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 xbt_fifo_t process_list;
35 /********************************* Task **************************************/
37 typedef struct simdata_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 simdata_process {
48 m_host_t host; /* the host on which the process is running */
49 xbt_context_t context; /* the context that executes the scheduler fonction */
50 int PID; /* used for debugging purposes */
51 int PPID; /* The parent PID */
52 m_task_t waiting_task;
53 m_host_t put_host; /* used for debugging purposes */
54 int put_channel; /* used for debugging purposes */
55 int argc; /* arguments number if any */
56 char **argv; /* arguments table if any */
57 MSG_error_t last_errno; /* the last value returned by a MSG_function */
58 } s_simdata_process_t;
60 /************************** Global variables ********************************/
61 typedef struct MSG_Global {
64 xbt_fifo_t process_to_run;
65 xbt_fifo_t process_list;
67 m_process_t current_process;
68 xbt_dict_t registered_functions;
69 } s_MSG_global_t, *MSG_Global_t;
71 extern MSG_Global_t msg_global;
73 /*************************************************************/
75 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
76 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
77 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
78 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
80 #define CHECK_HOST() xbt_assert0((MSG_host_self()->simdata->state==HOST_ALIVE),"Host failed, you cannot call this function.")
82 m_host_t __MSG_host_create(const char *name, void *workstation,
84 void __MSG_host_destroy(m_host_t host);
85 void __MSG_task_execute(m_process_t process, m_task_t task);
86 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task);
87 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);