task.hpp
1 #ifndef MAMMUT_PROCESS_HPP_
2 #define MAMMUT_PROCESS_HPP_
3 
4 #include "../module.hpp"
5 #include "../topology/topology.hpp"
6 
7 #include "sys/resource.h"
8 #define MAMMUT_PROCESS_PRIORITY_MIN 0
9 #define MAMMUT_PROCESS_PRIORITY_MAX (PRIO_MAX - PRIO_MIN)
10 
11 namespace mammut{
12 namespace task{
13 
14 typedef pid_t TaskId;
15 
16 class Task{
17 public:
28  virtual bool getCoreUsage(double& coreUsage) const = 0; //TODO: Time AND percentage
29 
35  virtual bool resetCoreUsage() = 0;
36 
45  virtual bool getPriority(uint& priority) const = 0;
46 
58  virtual bool setPriority(uint priority) const = 0;
59 
66  virtual bool getVirtualCoreId(topology::VirtualCoreId& virtualCoreId) const = 0;
67 
75  virtual bool move(const topology::Cpu* cpu) const = 0;
76 
84  virtual bool move(const topology::PhysicalCore* physicalCore) const = 0;
85 
93  virtual bool move(const topology::VirtualCore* virtualCore) const = 0;
94 
103  virtual bool move(topology::VirtualCoreId virtualCoreId) const = 0;
104 
111  virtual bool move(const std::vector<const topology::VirtualCore*> virtualCores) const = 0;
112 
120  virtual bool move(const std::vector<topology::VirtualCoreId> virtualCoresIds) const = 0;
121 
122  virtual ~Task(){;}
123 };
124 
125 class ThreadHandler: public virtual Task{
126 public:
127  virtual ~ThreadHandler(){;}
128 };
129 
130 class ProcessHandler: public virtual Task{
131 public:
136  virtual std::vector<TaskId> getActiveThreadsIdentifiers() const = 0;
137 
145  virtual ThreadHandler* getThreadHandler(TaskId tid) const = 0;
146 
151  virtual void releaseThreadHandler(ThreadHandler* thread) const = 0;
152 
153  virtual ~ProcessHandler(){;}
154 };
155 
156 class TasksManager: public Module{
157  MAMMUT_MODULE_DECL(TasksManager)
158 public:
163  virtual std::vector<TaskId> getActiveProcessesIdentifiers() const = 0;
164 
172  virtual ProcessHandler* getProcessHandler(TaskId pid) const = 0;
173 
178  virtual void releaseProcessHandler(ProcessHandler* process) const = 0;
179 
188  virtual ThreadHandler* getThreadHandler(TaskId pid, TaskId tid) const = 0;
189 
196  virtual ThreadHandler* getThreadHandler() const = 0;
197 
202  virtual void releaseThreadHandler(ThreadHandler* thread) const = 0;
203 };
204 
205 }
206 }
207 
208 #endif /* MAMMUT_PROCESS_HPP_ */
virtual void releaseThreadHandler(ThreadHandler *thread) const =0
virtual bool getCoreUsage(double &coreUsage) const =0
virtual std::vector< TaskId > getActiveProcessesIdentifiers() const =0
virtual void releaseProcessHandler(ProcessHandler *process) const =0
Definition: topology.hpp:445
Definition: task.hpp:156
virtual ThreadHandler * getThreadHandler() const =0
virtual bool resetCoreUsage()=0
Definition: topology.hpp:127
Definition: task.hpp:16
virtual bool getVirtualCoreId(topology::VirtualCoreId &virtualCoreId) const =0
virtual bool setPriority(uint priority) const =0
virtual void releaseThreadHandler(ThreadHandler *thread) const =0
Definition: topology.hpp:239
virtual ProcessHandler * getProcessHandler(TaskId pid) const =0
virtual std::vector< TaskId > getActiveThreadsIdentifiers() const =0
virtual bool move(const topology::Cpu *cpu) const =0
virtual bool getPriority(uint &priority) const =0
virtual ThreadHandler * getThreadHandler(TaskId tid) const =0
Definition: task.hpp:125
Definition: task.hpp:130