.. _program_listing_file__tmp_ws_src_ecl_core_ecl_threads_include_ecl_threads_priority_pos.hpp: Program Listing for File priority_pos.hpp ========================================= |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ecl_core/ecl_threads/include/ecl/threads/priority_pos.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef ECL_THREADS_PRIORITY_POS_HPP_ #define ECL_THREADS_PRIORITY_POS_HPP_ /***************************************************************************** ** Platform Check *****************************************************************************/ #include #if defined(ECL_IS_POSIX) /***************************************************************************** ** Includes *****************************************************************************/ #include #include #include #include #include #include #include #include #include "priority_common.hpp" /***************************************************************************** ** Namespaces *****************************************************************************/ namespace ecl { bool ECL_PUBLIC set_priority(Priority priority_level); Priority ECL_PUBLIC get_priority(); std::string ECL_PUBLIC print_priority_diagnostics(); /***************************************************************************** ** Namespace *****************************************************************************/ namespace threads { bool ECL_LOCAL set_real_time_priority(int policy,int priority_level); } // namespace threads } // namespace ecl /***************************************************************************** ** Interface [Exceptions] *****************************************************************************/ #if defined(ECL_HAS_EXCEPTIONS) namespace ecl { namespace threads { /***************************************************************************** ** Interface [Priority Exceptions] *****************************************************************************/ inline StandardException ECL_LOCAL throwPriorityException(const char* loc ) { int error_result = errno; switch (error_result) { case ( EINVAL ) : return StandardException(loc, ecl::InvalidInputError, "The specified param structure or priority group was invalid."); case ( ESRCH ) : return StandardException(loc, ecl::InvalidInputError, "The process specified could not be found."); 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)."); 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)."); default : { std::ostringstream ostream; ostream << "Unknown posix error " << error_result << ": " << strerror(error_result) << "."; return StandardException(loc, UnknownError, ostream.str()); } } } } // namespace threads } // namespace ecl #endif /* ECL_HAS_EXCEPTIONS */ #endif /* ECL_IS_POSIX */ #endif /* ECL_THREADS_PRIORITY_POS_HPP_ */ // void yield(); // void capabilities() throw(StandardException); // * Yields this process (must be a real-time process) to lower priority processes. // * In effect, this places the process at the back of the cpu queue, even if there // * are lower priority processes ahead of it. // */ //inline void Process::yield() //{ // sched_yield(); //} // * Print out the posix capabilities of your program. // */ //inline void Process::capabilities() throw(StandardException) //{ // cap_t cap = cap_get_proc(); // // if (!cap) { // throw StandardException(LOC,"Could not retrieve posix characteristics.","Was not possible to retrieve the processes' posix capability list."); // } // std::cout << "Posix capabilities " << cap_to_text(cap,NULL) << std::endl; // cap_free(cap); //}