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 "simix/simix.h"
14 #include "xbt/dynar.h"
17 #include "xbt/context.h"
18 #include "xbt/config.h"
20 /**************** datatypes **********************************/
22 typedef struct simdata_host {
23 smx_host_t host; /* SURF modeling */
24 xbt_fifo_t *mbox; /* array of FIFOs used as a mailboxes */
25 smx_cond_t *sleeping; /* array of process used to know whether a local process is
26 waiting for a communication on a channel */
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 */
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_task_t waiting_task;
61 m_host_t put_host; /* used for debugging purposes */
62 m_channel_t put_channel; /* used for debugging purposes */
63 int argc; /* arguments number if any */
64 char **argv; /* arguments table if any */
65 MSG_error_t last_errno; /* the last value returned by a MSG_function */
66 } s_simdata_process_t;
68 typedef struct process_arg {
70 m_process_code_t code;
76 } s_process_arg_t, *process_arg_t;
78 /************************** Global variables ********************************/
79 typedef struct MSG_Global {
81 xbt_fifo_t process_list;
85 } s_MSG_Global_t, *MSG_Global_t;
87 extern MSG_Global_t msg_global;
89 /*************************************************************/
91 #define PROCESS_SET_ERRNO(val) (MSG_process_self()->simdata->last_errno=val)
92 #define PROCESS_GET_ERRNO() (MSG_process_self()->simdata->last_errno)
93 #define MSG_RETURN(val) do {PROCESS_SET_ERRNO(val);return(val);} while(0)
94 /* #define CHECK_ERRNO() ASSERT((PROCESS_GET_ERRNO()!=MSG_HOST_FAILURE),"Host failed, you cannot call this function.") */
96 #define CHECK_HOST() xbt_assert0(surf_workstation_resource->extension_public-> \
97 get_state(MSG_host_self()->simdata->host)==SURF_CPU_ON,\
98 "Host failed, you cannot call this function.")
100 m_host_t __MSG_host_create(smx_host_t workstation, void *data);
101 void __MSG_host_destroy(m_host_t host);
102 void __MSG_task_execute(m_process_t process, m_task_t task);
103 MSG_error_t __MSG_wait_for_computation(m_process_t process, m_task_t task);
104 MSG_error_t __MSG_task_wait_event(m_process_t process, m_task_t task);
106 int __MSG_process_block(double max_duration, const char *info);
107 MSG_error_t __MSG_process_unblock(m_process_t process);
108 int __MSG_process_isBlocked(m_process_t process);
110 void __MSG_display_process_status(void);