git(port_self): 修改线程分配
This commit is contained in:
parent
03ea55fdc9
commit
c618a1b918
BIN
build/crc16.o
BIN
build/crc16.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
erpc_core.c
18
erpc_core.c
|
@ -131,7 +131,7 @@ u32 erpc_send_base(erpc_hw_cfg_t *hw_cfg, u8 dest_id, u16 port, u8 package_type,
|
|||
{
|
||||
if (hw_cfg->send_cache[i].state == ERPC_CMD_NO_ERROR)
|
||||
{
|
||||
ERPC_DEBUG("find send cache %d\n", i);
|
||||
// ERPC_DEBUG("find send cache %d\n", i);
|
||||
cache_ord = i;
|
||||
break;
|
||||
}
|
||||
|
@ -377,7 +377,18 @@ u32 erpc_rev_package(erpc_hw_cfg_t *hw)
|
|||
{
|
||||
if (hw->rec_cache[i].state == ERPC_CMD_WAIT_SERVER_DEAL)
|
||||
{
|
||||
ERPC_DEBUG("find cmd wait server deal %d\n", i);
|
||||
hw->deal_lock();
|
||||
if (hw->rec_cache[i].state == ERPC_CMD_WAIT_SERVER_DEAL)
|
||||
{
|
||||
hw->rec_cache[i].state = ERPC_CMD_SERVER_DEAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
hw->deal_unlock();
|
||||
continue;
|
||||
}
|
||||
hw->deal_unlock();
|
||||
// ERPC_DEBUG("find cmd wait server deal %d\n", i);
|
||||
erpc_cmd_def_t *cmd = (erpc_cmd_def_t *)&hw->rec_cache[i].data[0];
|
||||
// 检查crc
|
||||
u8 crc_result = cmd_check_crc16(cmd);
|
||||
|
@ -403,6 +414,7 @@ u32 erpc_rev_package(erpc_hw_cfg_t *hw)
|
|||
break;
|
||||
case PACKAGE_TYPE_CMD_REQ_ACK:
|
||||
ERPC_DEBUG("{ACK}\n");
|
||||
|
||||
erpc_rev_ack_package(hw, cmd);
|
||||
hw->rec_cache[i].state = ERPC_CMD_NO_ERROR;
|
||||
break;
|
||||
|
@ -451,7 +463,7 @@ u32 erpc_set_rev_cahce(u8 hw, u8 *data, u16 len)
|
|||
{
|
||||
if (hw_cfg->rec_cache[i].state == ERPC_CMD_NO_ERROR)
|
||||
{
|
||||
ERPC_DEBUG("set rev cache %d\r\n", i);
|
||||
// ERPC_DEBUG("set rev cache %d\r\n", i);
|
||||
memcpy(hw_cfg->rec_cache[i].data, data, len);
|
||||
hw_cfg->rec_cache[i].state = ERPC_CMD_WAIT_SERVER_DEAL;
|
||||
return ERPC_NO_ERROR;
|
||||
|
|
|
@ -49,6 +49,7 @@ typedef enum erpc_status {
|
|||
ERPC_CMD_NO_ERROR, // 发送cache,接收cache空闲
|
||||
ERPC_CMD_DATA_DEAL, // 发送cache数据组织中
|
||||
ERPC_CMD_WAIT_SERVER_DEAL, // 等待服务线程处理接受cache
|
||||
ERPC_CMD_SERVER_DEAL, // 服务线程处理接受cache
|
||||
ERPC_CMD_WAIT_TASK_DEAL, // 等待任务线程处理指令
|
||||
ERPC_CMD_WAIT_TASK_DEAL_FINISH, // 等待任务线程处理指令完成
|
||||
ERPC_CMD_WAIT_SEND, // 等待服务线程处理发送cache
|
||||
|
|
18
port_self.c
18
port_self.c
|
@ -114,7 +114,19 @@ DWORD WINAPI send_task(LPVOID lpParam)
|
|||
erpc_send_deal_core();
|
||||
}
|
||||
}
|
||||
DWORD WINAPI rev_task(LPVOID lpParam)
|
||||
DWORD WINAPI rev_package_task(LPVOID lpParam)
|
||||
{
|
||||
UNUSED(lpParam);
|
||||
|
||||
while (1)
|
||||
{
|
||||
// ERPC_DEBUG("rev_task\n");
|
||||
erpc_rev_package_core();
|
||||
erpc_rev_deal_core();
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI rev_deal_task(LPVOID lpParam)
|
||||
{
|
||||
UNUSED(lpParam);
|
||||
|
||||
|
@ -180,8 +192,8 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
threadHandle[0] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)send_task, NULL, 0, NULL);
|
||||
threadHandle[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_task, NULL, 0, NULL);
|
||||
threadHandle[3] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_task, NULL, 0, NULL);
|
||||
threadHandle[1] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_package_task, NULL, 0, NULL);
|
||||
threadHandle[3] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)rev_deal_task, NULL, 0, NULL);
|
||||
threadHandle[4] = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)test_task, NULL, 0, NULL);
|
||||
|
||||
WaitForSingleObject(threadHandle[0], INFINITE);
|
||||
|
|
BIN
port_self.exe
BIN
port_self.exe
Binary file not shown.
Loading…
Reference in New Issue