Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memleak
[simgrid.git] / src / surf / vm_workstation.hpp
1 /*
2  * vm_workstation.hpp
3  *
4  *  Created on: Nov 12, 2013
5  *      Author: bedaride
6  */
7 #include "workstation.hpp"
8
9 #ifndef VM_WORKSTATION_HPP_
10 #define VM_WORKSTATION_HPP_
11
12 #define GUESTOS_NOISE 100 // This value corresponds to the cost of the global action associated to the VM
13                           // It corresponds to the cost of a VM running no tasks.
14
15 void surf_vm_workstation_model_init(void);
16
17 /*
18   void   (*create)  (const char *name, void *ind_phys_workstation); // First operation of the VM model
19   void   (*destroy) (void *ind_vm_ws); // will be vm_ws_destroy(), which destroies the vm-workstation-specific data
20
21   void   (*suspend) (void *ind_vm_ws);
22   void   (*resume)  (void *ind_vm_ws);
23
24   void   (*save)    (void *ind_vm_ws);
25   void   (*restore) (void *ind_vm_ws);
26
27   void   (*migrate) (void *ind_vm_ws, void *ind_vm_ws_dest); // will be vm_ws_migrate()
28
29   int    (*get_state) (void *ind_vm_ws);
30   void   (*set_state) (void *ind_vm_ws, int state);
31
32   void * (*get_pm) (void *ind_vm_ws); // will be vm_ws_get_pm()
33
34   void   (*set_vm_bound) (void *ind_vm_ws, double bound); // will be vm_ws_set_vm_bound()
35   void   (*set_vm_affinity) (void *ind_vm_ws, void *ind_pm_ws, unsigned long mask); // will be vm_ws_set_vm_affinity()
36 */
37
38 /***********
39  * Classes *
40  ***********/
41
42 class WorkstationVMModel;
43 typedef WorkstationVMModel *WorkstationVMModelPtr;
44
45 class WorkstationVM2013;
46 typedef WorkstationVM2013 *WorkstationVM2013Ptr;
47
48 class WorkstationVM2013Lmm;
49 typedef WorkstationVM2013Lmm *WorkstationVM2013LmmPtr;
50
51 /*********
52  * Tools *
53  *********/
54
55 /*********
56  * Model *
57  *********/
58 class WorkstationVMModel : public WorkstationModel {
59 public:
60   WorkstationVMModel();
61   ~WorkstationVMModel(){};
62   void createResource(const char *name, void *ind_phys_workstation);
63   double shareResources(double now);
64   void adjustWeightOfDummyCpuActions() {};
65 };
66
67 /************
68  * Resource *
69  ************/
70 class WorkstationVM2013 : virtual public WorkstationCLM03 {
71 public:
72   WorkstationVM2013(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
73    : WorkstationCLM03(model, name, props, NULL, netElm, cpu) {};
74
75   virtual void suspend()=0;
76   virtual void resume()=0;
77
78   virtual void save()=0;
79   virtual void restore()=0;
80
81   virtual void migrate(surf_resource_t ind_vm_ws_dest)=0; // will be vm_ws_migrate()
82
83   virtual surf_resource_t getPm()=0; // will be vm_ws_get_pm()
84
85   virtual void setBound(double bound)=0;
86   virtual void setAffinity(CpuLmmPtr cpu, unsigned long mask)=0;
87
88   /* The workstation object of the lower layer */
89   WorkstationCLM03Ptr p_subWs;  // Pointer to the ''host'' OS
90   e_surf_vm_state_t p_currentState;
91   CpuActionLmmPtr p_action;
92 };
93
94 class WorkstationVM2013Lmm : public WorkstationVM2013, public WorkstationCLM03Lmm {
95 public:
96   WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
97   ~WorkstationVM2013Lmm();
98
99   void suspend();
100   void resume();
101
102   void save();
103   void restore();
104
105   void migrate(surf_resource_t ind_dst_pm);
106
107   e_surf_resource_state_t getState();
108   void setState(e_surf_resource_state_t state);
109
110   surf_resource_t getPm(); // will be vm_ws_get_pm()
111
112   void setBound(double bound);
113   void setAffinity(CpuLmmPtr cpu, unsigned long mask);
114
115   //FIXME: remove
116   void updateState(tmgr_trace_event_t event_type, double value, double date) {
117         WorkstationCLM03Lmm::updateState(event_type, value, date);
118   }
119   bool isUsed() {
120     return WorkstationCLM03Lmm::isUsed();
121   }
122   xbt_dict_t getProperties() {
123     return WorkstationCLM03Lmm::getProperties();
124   }
125   ActionPtr execute(double size);
126
127 };
128
129 /**********
130  * Action *
131  **********/
132
133 #endif /* VM_WORKSTATION_HPP_ */