From 8c2eb4598f011833f5afdf61fae007462a6a03ff Mon Sep 17 00:00:00 2001 From: xj Date: Sun, 25 Aug 2024 20:33:16 -0700 Subject: [PATCH] merge codes --- .../XiZi_AIoT/softkernel/syscall/sys_sleep.c | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_sleep.c diff --git a/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_sleep.c b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_sleep.c new file mode 100644 index 000000000..bce382597 --- /dev/null +++ b/Ubiquitous/XiZi_AIoT/softkernel/syscall/sys_sleep.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 AIIT XUOS Lab + * XiUOS is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * You may obtain a copy of Mulan PSL v2 at: + * http://license.coscl.org.cn/MulanPSL2 + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, + * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, + * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ +/** + * @file sys_sleep.c + * @brief task sleep + * @version 3.0 + * @author AIIT XUOS Lab + * @date 2023.08.25 + */ + +/************************************************* +File name: sys_sleep.c +Description: +Others: +History: +1. Date: 2023-08-28 +Author: AIIT XUOS Lab +Modification: +1. first version +*************************************************/ +#include "multicores.h" +#include "syscall.h" +#include "task.h" + +#include "assert.h" + +int sys_sleep(intptr_t ms) +{ + struct Thread* cur_task = cur_cpu()->task; + xizi_task_manager.task_yield_noschedule(cur_task, false); + xizi_task_manager.task_block(&xizi_task_manager.task_sleep_list_head, cur_task); + cur_task->state = SLEEPING; + cur_task->sleep_context.remain_ms = ms; + + return 0; +} \ No newline at end of file