1 /* 2 * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved. 3 * 4 * UniProton is licensed under Mulan PSL v2. 5 * You can use this software according to the terms and conditions of the Mulan PSL v2. 6 * You may obtain a copy of Mulan PSL v2 at: 7 * http://license.coscl.org.cn/MulanPSL2 8 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 9 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 10 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 11 * See the Mulan PSL v2 for more details. 12 * Create: 2009-12-22 13 * Description: Task schedule implementation 14 */ 15 #include "prt_task_external.h" 16 #include "prt_sem_external.h" 17 18 #if defined(OS_OPTION_TASK_INFO) 19 /* 20 * 描述:获取阻塞任务的信号量 21 */ PRT_TaskGetPendSem(TskHandle taskId,U16 * semId,U16 * pendState)22OS_SEC_L4_TEXT U32 PRT_TaskGetPendSem(TskHandle taskId, U16 *semId, U16 *pendState) 23 { 24 uintptr_t intSave; 25 struct TagTskCb *taskCb = NULL; 26 27 if ((semId == NULL) || (pendState == NULL)) { 28 return OS_ERRNO_TSK_PTR_NULL; 29 } 30 31 *pendState = 0; 32 *semId = (U16)OS_INVALID; 33 if (CHECK_TSK_PID_OVERFLOW(taskId)) { 34 return OS_ERRNO_TSK_ID_INVALID; 35 } 36 37 taskCb = GET_TCB_HANDLE(taskId); 38 39 intSave = OsIntLock(); 40 if (TSK_IS_UNUSED(taskCb)) { 41 42 OsIntRestore(intSave); 43 44 return OS_ERRNO_TSK_NOT_CREATED; 45 } 46 47 *pendState = OS_TSK_PEND & taskCb->taskStatus; 48 49 if (*pendState == OS_TSK_PEND) { 50 *semId = ((struct TagSemCb *)taskCb->taskSem)->semId; 51 } 52 53 OsIntRestore(intSave); 54 55 return OS_OK; 56 } 57 #endif 58