forked from xuos/xiuos
feat support set task name using PrivTaskCreate in XiZi
This commit is contained in:
parent
6228e76194
commit
58fe8fc887
|
@ -335,10 +335,22 @@ void TestSocket(int argc, char* argv[])
|
||||||
if (mode == IPERF_MODE_SERVER) {
|
if (mode == IPERF_MODE_SERVER) {
|
||||||
printf("[%s] Running iperf server at port %d.\n", __func__, iperf_param.port);
|
printf("[%s] Running iperf server at port %d.\n", __func__, iperf_param.port);
|
||||||
|
|
||||||
PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&iperf_param);
|
#ifdef ADD_XIZI_FEATURES
|
||||||
|
char task_name[] = "test_iperf_server";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)&iperf_param;
|
||||||
|
PrivTaskCreate(&thd, NULL, TestIperfServer, (void*)&args);
|
||||||
|
#endif
|
||||||
} else if (mode == IPERF_MODE_CLIENT) {
|
} else if (mode == IPERF_MODE_CLIENT) {
|
||||||
printf("[%s] Running iperf client to server at %s:%d.\n", __func__, iperf_param.host, iperf_param.port);
|
printf("[%s] Running iperf client to server at %s:%d.\n", __func__, iperf_param.host, iperf_param.port);
|
||||||
PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&iperf_param);
|
#ifdef ADD_XIZI_FEATURES
|
||||||
|
char task_name[] = "test_iperf_client";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)&iperf_param;
|
||||||
|
PrivTaskCreate(&thd, NULL, TestIperfClient, (void*)&args);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivTaskStartup(&thd);
|
PrivTaskStartup(&thd);
|
||||||
|
|
|
@ -549,13 +549,19 @@ static int ATAgentInit(ATAgentType agent)
|
||||||
attr.priority = 18;
|
attr.priority = 18;
|
||||||
attr.stacksize = 8192;
|
attr.stacksize = 8192;
|
||||||
|
|
||||||
|
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
||||||
#else
|
#else
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
attr.schedparam.sched_priority = 25;
|
attr.schedparam.sched_priority = 25;
|
||||||
attr.stacksize = 4096;
|
attr.stacksize = 4096;
|
||||||
#endif
|
|
||||||
|
|
||||||
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, agent);
|
char task_name[] = "at_agent";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)agent;
|
||||||
|
|
||||||
|
PrivTaskCreate(&agent->at_handler, &attr, ATAgentReceiveProcess, (void *)&args);
|
||||||
|
#endif
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
|
|
|
@ -848,8 +848,10 @@ static int AdapterLoraRegister(struct Adapter *adapter)
|
||||||
ret = AdapterDeviceRegister(adapter);
|
ret = AdapterDeviceRegister(adapter);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Adapter4G register error\n");
|
printf("Adapter4G register error\n");
|
||||||
|
#ifdef AS_LORA_GATEWAY_ROLE
|
||||||
if (lora_gateway)
|
if (lora_gateway)
|
||||||
PrivFree(lora_gateway);
|
PrivFree(lora_gateway);
|
||||||
|
#endif
|
||||||
if (lora_client)
|
if (lora_client)
|
||||||
PrivFree(lora_client);
|
PrivFree(lora_client);
|
||||||
|
|
||||||
|
@ -952,22 +954,32 @@ int AdapterLoraTest(void)
|
||||||
pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER;
|
pthread_attr_t lora_gateway_attr = PTHREAD_ATTR_INITIALIZER;
|
||||||
lora_gateway_attr.priority = 20;
|
lora_gateway_attr.priority = 20;
|
||||||
lora_gateway_attr.stacksize = 2048;
|
lora_gateway_attr.stacksize = 2048;
|
||||||
|
PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)adapter);
|
||||||
#else
|
#else
|
||||||
pthread_attr_t lora_gateway_attr;
|
pthread_attr_t lora_gateway_attr;
|
||||||
lora_gateway_attr.schedparam.sched_priority = 20;
|
lora_gateway_attr.schedparam.sched_priority = 20;
|
||||||
lora_gateway_attr.stacksize = 2048;
|
lora_gateway_attr.stacksize = 2048;
|
||||||
|
|
||||||
|
char task_name_1[] = "adapter_lora_recv";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name_1;
|
||||||
|
args.arg = (void *)adapter;
|
||||||
|
PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)&args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)adapter);
|
|
||||||
PrivTaskStartup(&lora_recv_data_task);
|
PrivTaskStartup(&lora_recv_data_task);
|
||||||
|
|
||||||
#ifdef ADD_NUTTX_FEATURES
|
#ifdef ADD_NUTTX_FEATURES
|
||||||
lora_gateway_attr.priority = 20;
|
lora_gateway_attr.priority = 20;
|
||||||
|
PrivTaskCreate(&lora_gateway_task, &lora_gateway_attr, &LoraGatewayTask, (void *)adapter);
|
||||||
#else
|
#else
|
||||||
lora_gateway_attr.schedparam.sched_priority = 20;
|
lora_gateway_attr.schedparam.sched_priority = 20;
|
||||||
|
char task_name_2[] = "adapter_lora_gateway";
|
||||||
|
args.pthread_name = task_name_2;
|
||||||
|
args.arg = (void *)adapter;
|
||||||
|
PrivTaskCreate(&lora_recv_data_task, &lora_gateway_attr, &LoraReceiveTask, (void *)&args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PrivTaskCreate(&lora_gateway_task, &lora_gateway_attr, &LoraGatewayTask, (void *)adapter);
|
|
||||||
PrivTaskStartup(&lora_gateway_task);
|
PrivTaskStartup(&lora_gateway_task);
|
||||||
|
|
||||||
#else //AS_LORA_CLIENT_ROLE
|
#else //AS_LORA_CLIENT_ROLE
|
||||||
|
@ -975,22 +987,34 @@ int AdapterLoraTest(void)
|
||||||
pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER;
|
pthread_attr_t lora_client_attr = PTHREAD_ATTR_INITIALIZER;
|
||||||
lora_client_attr.priority = 20;
|
lora_client_attr.priority = 20;
|
||||||
lora_client_attr.stacksize = 2048;
|
lora_client_attr.stacksize = 2048;
|
||||||
|
|
||||||
|
PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)adapter);
|
||||||
#else
|
#else
|
||||||
pthread_attr_t lora_client_attr;
|
pthread_attr_t lora_client_attr;
|
||||||
lora_client_attr.schedparam.sched_priority = 20;
|
lora_client_attr.schedparam.sched_priority = 20;
|
||||||
lora_client_attr.stacksize = 2048;
|
lora_client_attr.stacksize = 2048;
|
||||||
|
|
||||||
|
char task_name_1[] = "adapter_lora_recv";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name_1;
|
||||||
|
args.arg = (void *)adapter;
|
||||||
|
PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)&args);
|
||||||
#endif
|
#endif
|
||||||
PrivTaskCreate(&lora_recv_data_task, &lora_client_attr, &LoraReceiveTask, (void *)adapter);
|
|
||||||
PrivTaskStartup(&lora_recv_data_task);
|
PrivTaskStartup(&lora_recv_data_task);
|
||||||
|
|
||||||
#ifdef ADD_NUTTX_FEATURES
|
#ifdef ADD_NUTTX_FEATURES
|
||||||
lora_client_attr.priority = 20;
|
lora_client_attr.priority = 20;
|
||||||
|
PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)adapter);
|
||||||
#else
|
#else
|
||||||
lora_client_attr.schedparam.sched_priority = 20;
|
lora_client_attr.schedparam.sched_priority = 20;
|
||||||
|
char task_name_2[] = "adapter_lora_client";
|
||||||
|
args.pthread_name = task_name_2;
|
||||||
|
args.arg = (void *)adapter;
|
||||||
|
PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)&args);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//create lora client task
|
//create lora client task
|
||||||
PrivTaskCreate(&lora_client_data_task, &lora_client_attr, &LoraClientDataTask, (void *)adapter);
|
|
||||||
PrivTaskStartup(&lora_client_data_task);
|
PrivTaskStartup(&lora_client_data_task);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -322,7 +322,12 @@ int ControlProtocolOpenDef(struct ControlProtocol *control_protocol)
|
||||||
attr.schedparam.sched_priority = 19;
|
attr.schedparam.sched_priority = 19;
|
||||||
attr.stacksize = 2048;
|
attr.stacksize = 2048;
|
||||||
|
|
||||||
PrivTaskCreate(&recv_plc_data_task, &attr, &ReceivePlcDataTask, control_protocol);
|
char task_name[] = "control_recv_data";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)control_protocol;
|
||||||
|
|
||||||
|
PrivTaskCreate(&recv_plc_data_task, &attr, &ReceivePlcDataTask, (void *)&args);
|
||||||
PrivTaskStartup(&recv_plc_data_task);
|
PrivTaskStartup(&recv_plc_data_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,12 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||||
|
|
||||||
result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
|
result = PrivIoctl(sdev->fd, OPE_INT, &cfg);
|
||||||
|
|
||||||
PrivTaskCreate(&active_task_id, NULL, &ReadTask, sdev);
|
char task_name[] = "ps5308_recv_data";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)sdev;
|
||||||
|
|
||||||
|
PrivTaskCreate(&active_task_id, NULL, &ReadTask, (void *)&args);
|
||||||
PrivTaskStartup(&active_task_id);
|
PrivTaskStartup(&active_task_id);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -116,7 +116,12 @@ static int SensorDeviceOpen(struct SensorDevice *sdev)
|
||||||
attr.schedparam.sched_priority = 20;
|
attr.schedparam.sched_priority = 20;
|
||||||
attr.stacksize = 2048;
|
attr.stacksize = 2048;
|
||||||
|
|
||||||
PrivTaskCreate(&active_task_id, &attr, &ReadTask, sdev);
|
char task_name[] = "d124_recv_data";
|
||||||
|
pthread_args_t args;
|
||||||
|
args.pthread_name = task_name;
|
||||||
|
args.arg = (void *)sdev;
|
||||||
|
|
||||||
|
PrivTaskCreate(&active_task_id, &attr, &ReadTask, (void *)&args);
|
||||||
PrivTaskStartup(&active_task_id);
|
PrivTaskStartup(&active_task_id);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -72,6 +72,11 @@ extern "C" {
|
||||||
|
|
||||||
typedef int pid_t;
|
typedef int pid_t;
|
||||||
// typedef int pthread_mutex_t ;
|
// typedef int pthread_mutex_t ;
|
||||||
|
typedef struct pthread_args
|
||||||
|
{
|
||||||
|
void *arg;
|
||||||
|
const char *pthread_name;
|
||||||
|
}pthread_args_t;
|
||||||
|
|
||||||
/* scheduling algorithms */
|
/* scheduling algorithms */
|
||||||
#define SCHED_OTHER 0
|
#define SCHED_OTHER 0
|
||||||
|
|
|
@ -34,6 +34,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
char task_name[32] = {0};
|
char task_name[32] = {0};
|
||||||
static int utask_id = 0;
|
static int utask_id = 0;
|
||||||
UtaskType task;
|
UtaskType task;
|
||||||
|
pthread_args_t *pthread_args = (pthread_args_t *)arg;
|
||||||
|
|
||||||
if (NULL == attr) {
|
if (NULL == attr) {
|
||||||
task.prio = KTASK_PRIORITY_MAX / 2;
|
task.prio = KTASK_PRIORITY_MAX / 2;
|
||||||
|
@ -44,8 +45,19 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||||
}
|
}
|
||||||
|
|
||||||
task.func_entry = start_routine;
|
task.func_entry = start_routine;
|
||||||
task.func_param = arg;
|
|
||||||
|
if (NULL == pthread_args) {
|
||||||
|
task.func_param = NULL;
|
||||||
snprintf(task_name, sizeof(task_name) - 1, "utask%02d", utask_id++);
|
snprintf(task_name, sizeof(task_name) - 1, "utask%02d", utask_id++);
|
||||||
|
} else {
|
||||||
|
task.func_param = pthread_args->arg;
|
||||||
|
if (NULL == pthread_args->pthread_name) {
|
||||||
|
snprintf(task_name, sizeof(task_name) - 1, "utask%02d", utask_id++);
|
||||||
|
} else {
|
||||||
|
snprintf(task_name, sizeof(task_name) - 1, pthread_args->pthread_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(task.name , task_name, sizeof(task_name) - 1);
|
memcpy(task.name , task_name, sizeof(task_name) - 1);
|
||||||
|
|
||||||
pid = UserTaskCreate(task);
|
pid = UserTaskCreate(task);
|
||||||
|
|
|
@ -78,7 +78,11 @@ int timer_create(clockid_t clockid, struct sigevent * evp, timer_t * timerid)
|
||||||
attr.schedparam.sched_priority = 22;
|
attr.schedparam.sched_priority = 22;
|
||||||
attr.stacksize = 2048;
|
attr.stacksize = 2048;
|
||||||
|
|
||||||
pthread_create(&timer_task, &attr, &timer_callback, (void *)evp);
|
pthread_args_t args;
|
||||||
|
args.pthread_name = timer_name;
|
||||||
|
args.arg = (void *)evp;
|
||||||
|
|
||||||
|
pthread_create(&timer_task, &attr, &timer_callback, (void *)&args);
|
||||||
|
|
||||||
timer_id = UserTimerCreate(timer_name, NULL, (void *)&timer_sem, 1000, g_timer_func.timer_flags);
|
timer_id = UserTimerCreate(timer_name, NULL, (void *)&timer_sem, 1000, g_timer_func.timer_flags);
|
||||||
*timerid = timer_id;
|
*timerid = timer_id;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit a94c007cb4ee726cc29b10626f8bbfc19c989b89
|
Subproject commit e5aa3f22196165200226daab9288ffc537980bf6
|
Loading…
Reference in New Issue