Go to the documentation of this file.00001
00008
00009
00010
00011
00012 #ifndef ECL_THREADS_PRIORITY_POS_HPP_
00013 #define ECL_THREADS_PRIORITY_POS_HPP_
00014
00015
00016
00017
00018
00019 #include <ecl/config/ecl.hpp>
00020 #if defined(ECL_IS_POSIX)
00021
00022
00023
00024
00025
00026 #include <unistd.h>
00027 #include <string>
00028 #include <sstream>
00029 #include <errno.h>
00030 #include <sys/resource.h>
00031 #include <ecl/config/ecl.hpp>
00032 #include <ecl/exceptions/macros.hpp>
00033 #include <ecl/exceptions/standard_exception.hpp>
00034 #include "priority_common.hpp"
00035
00036
00037
00038
00039
00040 namespace ecl {
00041
00106 bool ECL_PUBLIC set_priority(Priority priority_level) ecl_debug_throw_decl(StandardException);
00113 Priority ECL_PUBLIC get_priority() ecl_debug_throw_decl(StandardException);
00114
00120 std::string ECL_PUBLIC print_priority_diagnostics() ecl_debug_throw_decl(StandardException);
00121
00122
00123
00124
00125
00126 namespace threads {
00127
00143 bool ECL_LOCAL set_real_time_priority(int policy,int priority_level) ecl_debug_throw_decl(StandardException);
00144
00145 }
00146 }
00147
00148
00149
00150
00151
00152 #if defined(ECL_HAS_EXCEPTIONS)
00153 namespace ecl {
00154 namespace threads {
00155
00156
00157
00158
00171 inline StandardException ECL_LOCAL throwPriorityException(const char* loc ) {
00172 int error_result = errno;
00173 switch (error_result) {
00174 case ( EINVAL ) : return StandardException(loc, ecl::InvalidInputError, "The specified param structure or priority group was invalid.");
00175 case ( ESRCH ) : return StandardException(loc, ecl::InvalidInputError, "The process specified could not be found.");
00176 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).");
00177 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).");
00178 default :
00179 {
00180 std::ostringstream ostream;
00181 ostream << "Unknown posix error " << error_result << ": " << strerror(error_result) << ".";
00182 return StandardException(loc, UnknownError, ostream.str());
00183 }
00184 }
00185 }
00186
00187
00188 };
00189 }
00190 #endif
00191 #endif
00192 #endif
00193
00194
00195
00196
00197
00198
00200
00201
00202
00203
00204
00205
00206
00207
00208
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222