[DEBUG] correct safe thread set name and add back thread priority

This commit is contained in:
Edouard DUPIN 2017-10-14 10:43:32 +02:00
parent d5ef0aa31f
commit 4a38787d22

View File

@ -48,21 +48,21 @@ namespace ethread {
etk::Map<uint64_t,etk::String>& list = getThreadList(); etk::Map<uint64_t,etk::String>& list = getThreadList();
uint32_t threadID = getThreadHumanId(_id); uint32_t threadID = getThreadHumanId(_id);
etk::String out; etk::String out;
// TODO: g_lock.lock(); g_lock.lock();
auto it = list.find(threadID); auto it = list.find(threadID);
if (it != list.end()) { if (it != list.end()) {
out = it.getValue(); out = it.getValue();
} }
// TODO: g_lock.unlock(); g_lock.unLock();
return out; return out;
} }
void setThreadName(ethread::Thread* _thread, const etk::String& _name) { void setThreadName(ethread::Thread* _thread, const etk::String& _name) {
etk::Map<uint64_t,etk::String>& list = getThreadList(); etk::Map<uint64_t,etk::String>& list = getThreadList();
uint32_t threadID = ethread::getId(); uint32_t threadID = ethread::getId();
// TODO: g_lock.lock(); g_lock.lock();
list.set(threadID, _name); list.set(threadID, _name);
// TODO: g_lock.unlock(); g_lock.unLock();
// try now to set the thread name with Pthread // try now to set the thread name with Pthread
#if ( defined(__TARGET_OS__Linux) \ #if ( defined(__TARGET_OS__Linux) \
|| defined(__TARGET_OS__Android) \ || defined(__TARGET_OS__Android) \
@ -119,7 +119,6 @@ etk::String ethread::getName(ethread::Thread& _thread) {
#if defined(__TARGET_OS__Linux) \ #if defined(__TARGET_OS__Linux) \
&& !defined(__TARGET_OS__Web) && !defined(__TARGET_OS__Web)
static void setThreadPriority(pthread_t _threadID, int32_t _priority) { static void setThreadPriority(pthread_t _threadID, int32_t _priority) {
#if 0
int retcode; int retcode;
int policy; int policy;
struct sched_param param; struct sched_param param;
@ -143,10 +142,8 @@ etk::String ethread::getName(ethread::Thread& _thread) {
"???") ); "???") );
*/ */
} }
#endif
} }
static int32_t getThreadPriority(pthread_t _threadID) { static int32_t getThreadPriority(pthread_t _threadID) {
/*
int retcode; int retcode;
int policy; int policy;
struct sched_param param; struct sched_param param;
@ -159,35 +156,28 @@ etk::String ethread::getName(ethread::Thread& _thread) {
return -param.sched_priority; return -param.sched_priority;
} }
return param.sched_priority; return param.sched_priority;
*/
return 0; return 0;
} }
#endif #endif
void ethread::setPriority(int32_t _priority) { void ethread::setPriority(int32_t _priority) {
/*
#if defined(__TARGET_OS__Linux) \ #if defined(__TARGET_OS__Linux) \
&& !defined(__TARGET_OS__Web) && !defined(__TARGET_OS__Web)
pthread_t threadID = pthread_self(); pthread_t threadID = pthread_self();
setThreadPriority(threadID, _priority); setThreadPriority(threadID, _priority);
#endif #endif
*/
} }
void ethread::setPriority(ethread::Thread& _thread, int32_t _priority) { void ethread::setPriority(ethread::Thread& _thread, int32_t _priority) {
/*
#if defined(__TARGET_OS__Linux) \ #if defined(__TARGET_OS__Linux) \
&& !defined(__TARGET_OS__Web) && !defined(__TARGET_OS__Web)
pthread_t threadID = (pthread_t) _thread.native_handle(); pthread_t threadID = _thread.getNativeHandle();
setThreadPriority(threadID, _priority); setThreadPriority(threadID, _priority);
#endif #endif
*/
} }
int32_t ethread::getPriority() { int32_t ethread::getPriority() {
/*
#if defined(__TARGET_OS__Linux) \ #if defined(__TARGET_OS__Linux) \
&& !defined(__TARGET_OS__Web) && !defined(__TARGET_OS__Web)
pthread_t threadID = pthread_self(); pthread_t threadID = pthread_self();
@ -195,21 +185,16 @@ int32_t ethread::getPriority() {
#else #else
return 20; return 20;
#endif #endif
*/
return 20;
} }
int32_t ethread::getPriority(ethread::Thread& _thread) { int32_t ethread::getPriority(ethread::Thread& _thread) {
/*
#if defined(__TARGET_OS__Linux) \ #if defined(__TARGET_OS__Linux) \
&& !defined(__TARGET_OS__Web) && !defined(__TARGET_OS__Web)
pthread_t threadID = static_cast<pthread_t>(_thread.native_handle()); pthread_t threadID = _thread.getNativeHandle();
return getThreadPriority(threadID); return getThreadPriority(threadID);
#else #else
return 20; return 20;
#endif #endif
*/
return 20;
} }
//static ethread::Mutex g_localMutex; //static ethread::Mutex g_localMutex;