priority_pos.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_THREADS_PRIORITY_POS_HPP_
13 #define ECL_THREADS_PRIORITY_POS_HPP_
14 
15 /*****************************************************************************
16 ** Platform Check
17 *****************************************************************************/
18 
19 #include <ecl/config/ecl.hpp>
20 #if defined(ECL_IS_POSIX)
21 
22 /*****************************************************************************
23 ** Includes
24 *****************************************************************************/
25 
26 #include <unistd.h>
27 #include <string>
28 #include <sstream>
29 #include <errno.h>
30 #include <sys/resource.h>
31 #include <ecl/config/ecl.hpp>
34 #include "priority_common.hpp"
35 
36 /*****************************************************************************
37 ** Namespaces
38 *****************************************************************************/
39 
40 namespace ecl {
41 
106 bool ECL_PUBLIC set_priority(Priority priority_level) ecl_debug_throw_decl(StandardException);
113 Priority ECL_PUBLIC get_priority() ecl_debug_throw_decl(StandardException);
114 
120 std::string ECL_PUBLIC print_priority_diagnostics() ecl_debug_throw_decl(StandardException);
121 
122 /*****************************************************************************
123 ** Namespace
124 *****************************************************************************/
125 
126 namespace threads {
127 
143 bool ECL_LOCAL set_real_time_priority(int policy,int priority_level) ecl_debug_throw_decl(StandardException);
144 
145 } // namespace threads
146 } // namespace ecl
147 
148 /*****************************************************************************
149 ** Interface [Exceptions]
150 *****************************************************************************/
151 
152 #if defined(ECL_HAS_EXCEPTIONS)
153 namespace ecl {
154 namespace threads {
155 
156 /*****************************************************************************
157 ** Interface [Priority Exceptions]
158 *****************************************************************************/
171 inline StandardException ECL_LOCAL throwPriorityException(const char* loc ) {
172  int error_result = errno;
173  switch (error_result) {
174  case ( EINVAL ) : return StandardException(loc, ecl::InvalidInputError, "The specified param structure or priority group was invalid.");
175  case ( ESRCH ) : return StandardException(loc, ecl::InvalidInputError, "The process specified could not be found.");
176  case ( EPERM ) : return StandardException(loc, ecl::PermissionsError, "The caller does not have the appropriate privileges for realtime scheduling (http://snorriheim.dnsdojo.com/doku/doku.php/en:linux:admin:priorities).");
177  case ( EACCES ) : return StandardException(loc, ecl::PermissionsError, "The caller does not have the appropriate privileges for elevating the process priority by reducing the niceness value (http://snorriheim.dnsdojo.com/doku/doku.php/en:linux:admin:priorities).");
178  default :
179  {
180  std::ostringstream ostream;
181  ostream << "Unknown posix error " << error_result << ": " << strerror(error_result) << ".";
182  return StandardException(loc, UnknownError, ostream.str());
183  }
184  }
185 }
186 
187 
188 }; // namespace threads
189 } // namespace ecl
190 #endif /* ECL_HAS_EXCEPTIONS */
191 #endif /* ECL_IS_POSIX */
192 #endif /* ECL_THREADS_PRIORITY_POS_HPP_ */
193 
194 
195 // void yield();
196 // void capabilities() throw(StandardException);
197 
198 
200 // * Yields this process (must be a real-time process) to lower priority processes.
201 // * In effect, this places the process at the back of the cpu queue, even if there
202 // * are lower priority processes ahead of it.
203 // */
204 //inline void Process::yield()
205 //{
206 // sched_yield();
207 //}
208 
210 // * Print out the posix capabilities of your program.
211 // */
212 //inline void Process::capabilities() throw(StandardException)
213 //{
214 // cap_t cap = cap_get_proc();
215 //
216 // if (!cap) {
217 // throw StandardException(LOC,"Could not retrieve posix characteristics.","Was not possible to retrieve the processes' posix capability list.");
218 // }
219 // std::cout << "Posix capabilities " << cap_to_text(cap,NULL) << std::endl;
220 // cap_free(cap);
221 //}
222 
Embedded control libraries.
Common types for priority scheduling.
PermissionsError
UnknownError
InvalidInputError
#define ecl_debug_throw_decl(exception)
#define ECL_LOCAL
#define ECL_PUBLIC
Priority
Shared abstraction of the scheduling priorities.


ecl_threads
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:44