diff --git a/Ubiquitous/XiZi_AIoT/services/lib/ipc/libipc.c b/Ubiquitous/XiZi_AIoT/services/lib/ipc/libipc.c index ca047a429..7c3e22302 100644 --- a/Ubiquitous/XiZi_AIoT/services/lib/ipc/libipc.c +++ b/Ubiquitous/XiZi_AIoT/services/lib/ipc/libipc.c @@ -173,11 +173,14 @@ void ipc_server_loop(struct IpcNode* ipc_node) */ poll_session(session_list, NR_MAX_SESSION); /* handle each session */ - for (int repeat = 0; repeat <= 1; repeat++) { + bool has_delayed = true; + for (int repeat = 0; repeat <= 1 && has_delayed; repeat++) { + has_delayed = false; for (int i = 0; i < NR_MAX_SESSION; i++) { + session_delayed = false; if (session_list[i].buf == NULL) { yield(SYS_TASK_YIELD_NO_REASON); - continue; + break; } cur_sess_id = session_list[i].id; struct IpcMsg* msg = IPCSESSION_MSG(&session_list[i]); @@ -197,7 +200,7 @@ void ipc_server_loop(struct IpcNode* ipc_node) // check if this session is delayed by op handler, all messages after the delayed message in current session is blocked. if (is_cur_session_delayed()) { msg->header.delayed = 1; - session_delayed = false; + has_delayed = true; break; } } else { diff --git a/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_poll_session.c b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_poll_session.c index 5771324ea..ad11b70eb 100644 --- a/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_poll_session.c +++ b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_poll_session.c @@ -81,6 +81,7 @@ int sys_poll_session(struct Session* userland_session_arr, int arr_capacity) /* poll with new sessions */ int nr_sessions_need_to_handle = 0; + bool has_middle_delete = false; int session_idx = 0; DOUBLE_LIST_FOR_EACH_ENTRY(server_session, &cur_task->svr_sess_listhead, node) { @@ -97,6 +98,7 @@ int sys_poll_session(struct Session* userland_session_arr, int arr_capacity) xizi_share_page_manager.unmap_task_share_pages(cur_task, session_backend->server_side.buf_addr, session_backend->nr_pages); } xizi_share_page_manager.delete_share_pages(session_backend); + has_middle_delete = true; break; } @@ -115,9 +117,12 @@ int sys_poll_session(struct Session* userland_session_arr, int arr_capacity) session_idx++; } - if (session_idx < arr_capacity && nr_sessions_need_to_handle == 0) { - userland_session_arr[session_idx].buf = 0; - sys_yield(SYS_TASK_YIELD_BLOCK_IPC); + if (session_idx < arr_capacity) { + userland_session_arr[session_idx].buf = NULL; + if (!has_middle_delete && nr_sessions_need_to_handle == 0) { + xizi_task_manager.task_yield_noschedule(cur_task, false); + xizi_task_manager.task_block(cur_task); + } } return 0;