set thread name as necessary
parent
9d9cee76ac
commit
082da383ff
3
HISTORY
3
HISTORY
|
|
@ -1,7 +1,8 @@
|
||||||
|
|
||||||
Version 1.50 2021-04-28
|
Version 1.50 2021-04-29
|
||||||
* add function is_digital_string
|
* add function is_digital_string
|
||||||
* add function fc_server_load_from_ini_context
|
* add function fc_server_load_from_ini_context
|
||||||
|
* set thread name as necessary
|
||||||
|
|
||||||
Version 1.49 2021-04-17
|
Version 1.49 2021-04-17
|
||||||
* add macros: FC_ABS and FC_NEGATIVE
|
* add macros: FC_ABS and FC_NEGATIVE
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "shared_func.h"
|
#include "shared_func.h"
|
||||||
#include "pthread_func.h"
|
#include "pthread_func.h"
|
||||||
#include "logger.h"
|
#include "logger.h"
|
||||||
|
|
@ -377,6 +382,10 @@ static void *sched_call_func(void *args)
|
||||||
TaskFunc task_func;
|
TaskFunc task_func;
|
||||||
int task_id;
|
int task_id;
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
prctl(PR_SET_NAME, "sched-call");
|
||||||
|
#endif
|
||||||
|
|
||||||
pEntry = (ScheduleEntry *)args;
|
pEntry = (ScheduleEntry *)args;
|
||||||
task_func = pEntry->task_func;
|
task_func = pEntry->task_func;
|
||||||
func_args = pEntry->func_args;
|
func_args = pEntry->func_args;
|
||||||
|
|
@ -405,6 +414,10 @@ static void *sched_thread_entrance(void *args)
|
||||||
int exec_count;
|
int exec_count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
prctl(PR_SET_NAME, "sched");
|
||||||
|
#endif
|
||||||
|
|
||||||
pContext = (ScheduleContext *)args;
|
pContext = (ScheduleContext *)args;
|
||||||
if (sched_init_entries(pContext->scheduleArray.entries,
|
if (sched_init_entries(pContext->scheduleArray.entries,
|
||||||
pContext->scheduleArray.count) != 0)
|
pContext->scheduleArray.count) != 0)
|
||||||
|
|
@ -852,6 +865,10 @@ static void *sched_call_delay_func(void *args)
|
||||||
ScheduleContext *pContext;
|
ScheduleContext *pContext;
|
||||||
FastDelayTask *task;
|
FastDelayTask *task;
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
prctl(PR_SET_NAME, "sched-delay");
|
||||||
|
#endif
|
||||||
|
|
||||||
delay_context = (struct delay_thread_context *)args;
|
delay_context = (struct delay_thread_context *)args;
|
||||||
task = delay_context->task;
|
task = delay_context->task;
|
||||||
pContext = delay_context->schedule_context;
|
pContext = delay_context->schedule_context;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,11 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
#include <sys/prctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "sched_thread.h"
|
#include "sched_thread.h"
|
||||||
#include "fc_memory.h"
|
#include "fc_memory.h"
|
||||||
#include "thread_pool.h"
|
#include "thread_pool.h"
|
||||||
|
|
@ -36,6 +41,15 @@ static void *thread_entrance(void *arg)
|
||||||
thread = (FCThreadInfo *)arg;
|
thread = (FCThreadInfo *)arg;
|
||||||
pool = thread->pool;
|
pool = thread->pool;
|
||||||
|
|
||||||
|
#ifdef OS_LINUX
|
||||||
|
{
|
||||||
|
char thread_name[64];
|
||||||
|
snprintf(thread_name, sizeof(thread_name), "%s[%d]",
|
||||||
|
pool->name, thread->index);
|
||||||
|
prctl(PR_SET_NAME, thread_name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pool->extra_data_callbacks.alloc != NULL) {
|
if (pool->extra_data_callbacks.alloc != NULL) {
|
||||||
thread->tdata = pool->extra_data_callbacks.alloc();
|
thread->tdata = pool->extra_data_callbacks.alloc();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue