diff options
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index f5d5130..28f95f6 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -136,7 +136,7 @@ void Lane::startThread(int priority_) | |||
136 | m_thread = std::jthread([this]() { lane_main(this); }); | 136 | m_thread = std::jthread([this]() { lane_main(this); }); |
137 | if (priority_ != THREAD_PRIO_DEFAULT) | 137 | if (priority_ != THREAD_PRIO_DEFAULT) |
138 | { | 138 | { |
139 | JTHREAD_SET_PRIORITY(m_thread, priority_); | 139 | JTHREAD_SET_PRIORITY(m_thread, priority_, U->m_sudo); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | 142 | ||
@@ -784,7 +784,7 @@ LUAG_FUNC(get_debug_threadname) | |||
784 | 784 | ||
785 | LUAG_FUNC(set_thread_priority) | 785 | LUAG_FUNC(set_thread_priority) |
786 | { | 786 | { |
787 | int const prio{ (int) luaL_checkinteger(L, 1) }; | 787 | lua_Integer const prio{ luaL_checkinteger(L, 1) }; |
788 | // public Lanes API accepts a generic range -3/+3 | 788 | // public Lanes API accepts a generic range -3/+3 |
789 | // that will be remapped into the platform-specific scheduler priority scheme | 789 | // that will be remapped into the platform-specific scheduler priority scheme |
790 | // On some platforms, -3 is equivalent to -2 and +3 to +2 | 790 | // On some platforms, -3 is equivalent to -2 and +3 to +2 |
@@ -792,7 +792,7 @@ LUAG_FUNC(set_thread_priority) | |||
792 | { | 792 | { |
793 | return luaL_error(L, "priority out of range: %d..+%d (%d)", THREAD_PRIO_MIN, THREAD_PRIO_MAX, prio); | 793 | return luaL_error(L, "priority out of range: %d..+%d (%d)", THREAD_PRIO_MIN, THREAD_PRIO_MAX, prio); |
794 | } | 794 | } |
795 | THREAD_SET_PRIORITY(prio); | 795 | THREAD_SET_PRIORITY(static_cast<int>(prio), universe_get(L)->m_sudo); |
796 | return 0; | 796 | return 0; |
797 | } | 797 | } |
798 | 798 | ||
@@ -1746,32 +1746,6 @@ static void init_once_LOCKED( void) | |||
1746 | #if (defined PLATFORM_OSX) && (defined _UTILBINDTHREADTOCPU) | 1746 | #if (defined PLATFORM_OSX) && (defined _UTILBINDTHREADTOCPU) |
1747 | chudInitialize(); | 1747 | chudInitialize(); |
1748 | #endif | 1748 | #endif |
1749 | |||
1750 | //--- | ||
1751 | // Linux needs SCHED_RR to change thread priorities, and that is only | ||
1752 | // allowed for sudo'ers. SCHED_OTHER (default) has no priorities. | ||
1753 | // SCHED_OTHER threads are always lower priority than SCHED_RR. | ||
1754 | // | ||
1755 | // ^-- those apply to 2.6 kernel. IF **wishful thinking** these | ||
1756 | // constraints will change in the future, non-sudo priorities can | ||
1757 | // be enabled also for Linux. | ||
1758 | // | ||
1759 | #ifdef PLATFORM_LINUX | ||
1760 | sudo = (geteuid() == 0); // we are root? | ||
1761 | |||
1762 | // If lower priorities (-2..-1) are wanted, we need to lift the main | ||
1763 | // thread to SCHED_RR and 50 (medium) level. Otherwise, we're always below | ||
1764 | // the launched threads (even -2). | ||
1765 | // | ||
1766 | #ifdef LINUX_SCHED_RR | ||
1767 | if (sudo) | ||
1768 | { | ||
1769 | struct sched_param sp; | ||
1770 | sp.sched_priority = _PRIO_0; | ||
1771 | PT_CALL(pthread_setschedparam(pthread_self(), SCHED_RR, &sp)); | ||
1772 | } | ||
1773 | #endif // LINUX_SCHED_RR | ||
1774 | #endif // PLATFORM_LINUX | ||
1775 | } | 1749 | } |
1776 | 1750 | ||
1777 | // ################################################################################################# | 1751 | // ################################################################################################# |