priority_pos.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_THREADS_PRIORITY_POS_HPP_
00013 #define ECL_THREADS_PRIORITY_POS_HPP_
00014 
00015 /*****************************************************************************
00016 ** Platform Check
00017 *****************************************************************************/
00018 
00019 #include <ecl/config/ecl.hpp>
00020 #if defined(ECL_IS_POSIX)
00021 
00022 /*****************************************************************************
00023 ** Includes
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 ** Namespaces
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 ** Namespace
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 } // namespace threads
00146 } // namespace ecl
00147 
00148 /*****************************************************************************
00149 ** Interface [Exceptions]
00150 *****************************************************************************/
00151 
00152 #if defined(ECL_HAS_EXCEPTIONS)
00153 namespace ecl {
00154 namespace threads {
00155 
00156 /*****************************************************************************
00157 ** Interface [Priority Exceptions]
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 }; // namespace threads
00189 } // namespace ecl
00190 #endif /* ECL_HAS_EXCEPTIONS */
00191 #endif /* ECL_IS_POSIX */
00192 #endif /* ECL_THREADS_PRIORITY_POS_HPP_ */
00193 
00194 
00195 //        void yield();
00196 //        void capabilities() throw(StandardException);
00197 
00198 
00200 // * Yields this process (must be a real-time process) to lower priority processes.
00201 // * In effect, this places the process at the back of the cpu queue, even if there
00202 // * are lower priority processes ahead of it.
00203 // */
00204 //inline void Process::yield()
00205 //{
00206 //    sched_yield();
00207 //}
00208 
00210 // * Print out the posix capabilities of your program.
00211 // */
00212 //inline void Process::capabilities() throw(StandardException)
00213 //{
00214 //    cap_t cap = cap_get_proc();
00215 //
00216 //    if (!cap) {
00217 //        throw StandardException(LOC,"Could not retrieve posix characteristics.","Was not possible to retrieve the processes' posix capability list.");
00218 //    }
00219 //    std::cout << "Posix capabilities " << cap_to_text(cap,NULL) << std::endl;
00220 //    cap_free(cap);
00221 //}
00222 


ecl_threads
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:22