更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_task.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice, this list of
9 * conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
12 * of conditions and the following disclaimer in the documentation and/or other materials
13 * provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
16 * to endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/**
33 * @defgroup los_task Task
34 * @ingroup kernel
35 */
36
37#ifndef _LOS_TASK_H
38#define _LOS_TASK_H
39
40#include "los_base.h"
41#include "los_list.h"
42#include "los_sys.h"
43#include "los_tick.h"
44#include "los_event.h"
45#include "los_memory.h"
46#include "los_err.h"
47
48#ifdef __cplusplus
49#if __cplusplus
50extern "C" {
51#endif /* __cplusplus */
52#endif /* __cplusplus */
53//cpuid转换 2 -> 0100
54#define CPUID_TO_AFFI_MASK(cpuid) (0x1u << (cpuid))
55
56/**
57 * @ingroup los_task
58 * Flag that indicates the task or task control block status.
59 *
60 * The task is automatically deleted.
61 */
62#define LOS_TASK_STATUS_DETACHED 0x0U //独立模式,自动删除
63
64/**
65 * @ingroup los_task
66 * Flag that indicates the task or task control block status.
67 *
68 * The task is joinable.
69 */
70#define LOS_TASK_ATTR_JOINABLE 0x80000000 //联合模式,可由其他任务删除
71
72/**
73 * @ingroup los_task
74 * Task error code: Insufficient memory for task creation.
75 *
76 * Value: 0x03000200
77 *
78 * Solution: Allocate bigger memory partition to task creation.
79 */
80#define LOS_ERRNO_TSK_NO_MEMORY LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x00)
81
82/**
83 * @ingroup los_task
84 * Task error code: Null parameter.
85 *
86 * Value: 0x02000201
87 *
88 * Solution: Check the parameter.
89 */
90#define LOS_ERRNO_TSK_PTR_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x01)
91
92/**
93 * @ingroup los_task
94 * Task error code: The task stack is not aligned.
95 *
96 * Value: 0x02000202
97 *
98 * Solution: Align the task stack.
99 */
100#define LOS_ERRNO_TSK_STKSZ_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x02)
101
102/**
103 * @ingroup los_task
104 * Task error code: Incorrect task priority.
105 *
106 * Value: 0x02000203
107 *
108 * Solution: Re-configure the task priority by referring to the priority range.
109 */
110#define LOS_ERRNO_TSK_PRIOR_ERROR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x03)
111
112/**
113 * @ingroup los_task
114 * Task error code: The task entrance is NULL.
115 *
116 * Value: 0x02000204
117 *
118 * Solution: Define the task entrance function.
119 */
120#define LOS_ERRNO_TSK_ENTRY_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x04)
121
122/**
123 * @ingroup los_task
124 * Task error code: The task name is NULL.
125 *
126 * Value: 0x02000205
127 *
128 * Solution: Set the task name.
129 */
130#define LOS_ERRNO_TSK_NAME_EMPTY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x05)
131
132/**
133 * @ingroup los_task
134 * Task error code: The task stack size is too small.
135 *
136 * Value: 0x02000206
137 *
138 * Solution: Expand the task stack.
139 */
140#define LOS_ERRNO_TSK_STKSZ_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x06)
141
142/**
143 * @ingroup los_task
144 * Task error code: Invalid task ID.
145 *
146 * Value: 0x02000207
147 *
148 * Solution: Check the task ID.
149 */
150#define LOS_ERRNO_TSK_ID_INVALID LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x07)
151
152/**
153 * @ingroup los_task
154 * Task error code: The task is already suspended.
155 *
156 * Value: 0x02000208
157 *
158 * Solution: Suspend the task after it is resumed.
159 */
160#define LOS_ERRNO_TSK_ALREADY_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x08)
161
162/**
163 * @ingroup los_task
164 * Task error code: The task is not suspended.
165 *
166 * Value: 0x02000209
167 *
168 * Solution: Suspend the task.
169 */
170#define LOS_ERRNO_TSK_NOT_SUSPENDED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x09)
171
172/**
173 * @ingroup los_task
174 * Task error code: The task is not created.
175 *
176 * Value: 0x0200020a
177 *
178 * Solution: Create the task.
179 */
180#define LOS_ERRNO_TSK_NOT_CREATED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0a)
181
182/**
183 * @ingroup los_task
184 * Task error code: The task is locked when it is being deleted.
185 *
186 * Value: 0x0300020b
187 *
188 * Solution: Unlock the task.
189 */
190#define LOS_ERRNO_TSK_DELETE_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0b)
191
192/**
193 * @ingroup los_task
194 * Task error code: The task message is nonzero.
195 *
196 * Value: 0x0200020c
197 *
198 * Solution: This error code is not in use temporarily.
199 */
200#define LOS_ERRNO_TSK_MSG_NONZERO LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0c)
201
202/**
203 * @ingroup los_task
204 * Task error code: The task delay occurs during an interrupt.
205 *
206 * Value: 0x0300020d
207 *
208 * Solution: Perform this operation after exiting from the interrupt.
209 */
210#define LOS_ERRNO_TSK_DELAY_IN_INT LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x0d)
211
212/**
213 * @ingroup los_task
214 * Task error code: The task delay occurs when the task is locked.
215 *
216 * Value: 0x0200020e
217 *
218 * Solution: Perform this operation after unlocking the task.
219 */
220#define LOS_ERRNO_TSK_DELAY_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0e)
221
222/**
223 * @ingroup los_task
224 * Task error code: The task yeild occurs when the task is locked.
225 * Value: 0x0200020f
226 *
227 * Solution: Check the task.
228 */
229#define LOS_ERRNO_TSK_YIELD_IN_LOCK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x0f)
230
231/**
232 * @ingroup los_task
233 * Task error code: Only one task or no task is available for scheduling.
234 *
235 * Value: 0x02000210
236 *
237 * Solution: Increase the number of tasks.
238 */
239#define LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x10)
240
241/**
242 * @ingroup los_task
243 * Task error code: No free task control block is available.
244 *
245 * Value: 0x02000211
246 *
247 * Solution: Increase the number of task control blocks.
248 */
249#define LOS_ERRNO_TSK_TCB_UNAVAILABLE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x11)
250
251/**
252 * @ingroup los_task
253 * Task error code: The task hook function is not matchable.
254 *
255 * Value: 0x02000212
256 *
257 * Solution: This error code is not in use temporarily.
258 */
259#define LOS_ERRNO_TSK_HOOK_NOT_MATCH LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x12)
260
261/**
262 * @ingroup los_task
263 * Task error code: The number of task hook functions exceeds the permitted upper limit.
264 *
265 * Value: 0x02000213
266 *
267 * Solution: This error code is not in use temporarily.
268 */
269#define LOS_ERRNO_TSK_HOOK_IS_FULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x13)
270
271/**
272 * @ingroup los_task
273 * Task error code: The operation is performed on the system-level task.
274 * old usage: The operation is performed on the idle task (LOS_ERRNO_TSK_OPERATE_IDLE)
275 *
276 * Value: 0x02000214
277 *
278 * Solution: Check the task ID and do not operate on the system-level task.
279 */
280#define LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x14)
281
282/**
283 * @ingroup los_task
284 * Task error code: The task that is being suspended is locked.
285 *
286 * Value: 0x03000215
287 *
288 * Solution: Suspend the task after unlocking the task.
289 */
290#define LOS_ERRNO_TSK_SUSPEND_LOCKED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x15)
291
292/**
293 * @ingroup los_task
294 * Task error code: The task stack fails to be freed.
295 *
296 * Value: 0x02000217
297 *
298 * Solution: This error code is not in use temporarily.
299 */
300#define LOS_ERRNO_TSK_FREE_STACK_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x17)
301
302/**
303 * @ingroup los_task
304 * Task error code: The task stack area is too small.
305 *
306 * Value: 0x02000218
307 *
308 * Solution: This error code is not in use temporarily.
309 */
310#define LOS_ERRNO_TSK_STKAREA_TOO_SMALL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x18)
311
312/**
313 * @ingroup los_task
314 * Task error code: The task fails to be activated.
315 *
316 * Value: 0x03000219
317 *
318 * Solution: Perform task switching after creating an idle task.
319 */
320#define LOS_ERRNO_TSK_ACTIVE_FAILED LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x19)
321
322/**
323 * @ingroup los_task
324 * Task error code: Too many task configuration items.
325 *
326 * Value: 0x0200021a
327 *
328 * Solution: This error code is not in use temporarily.
329 */
330#define LOS_ERRNO_TSK_CONFIG_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1a)
331
332/**
333 * @ingroup los_task
334 * Task error code:
335 *
336 * Value: 0x0200021b
337 *
338 * Solution: This error code is not in use temporarily.
339 */
340#define LOS_ERRNO_TSK_CP_SAVE_AREA_NOT_ALIGN LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1b)
341
342/**
343 * @ingroup los_task
344 * Task error code:
345 *
346 * Value: 0x0200021d
347 *
348 * Solution: This error code is not in use temporarily.
349 */
350#define LOS_ERRNO_TSK_MSG_Q_TOO_MANY LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1d)
351
352/**
353 * @ingroup los_task
354 * Task error code:
355 *
356 * Value: 0x0200021e
357 *
358 * Solution: This error code is not in use temporarily.
359 */
360#define LOS_ERRNO_TSK_CP_SAVE_AREA_NULL LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1e)
361
362/**
363 * @ingroup los_task
364 * Task error code:
365 *
366 * Value: 0x0200021f
367 *
368 * Solution: This error code is not in use temporarily.
369 */
370#define LOS_ERRNO_TSK_SELF_DELETE_ERR LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x1f)
371
372/**
373 * @ingroup los_task
374 * Task error code: The task stack size is too large.
375 *
376 * Value: 0x02000220
377 *
378 * Solution: shrink the task stack size parameter.
379 */
380#define LOS_ERRNO_TSK_STKSZ_TOO_LARGE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x20)
381
382/**
383 * @ingroup los_task
384 * Task error code: Suspending software timer task is not allowed.
385 *
386 * Value: 0x02000221
387 *
388 * Solution: Check the task ID and do not suspend software timer task.
389 */
390#define LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x21)
391
392/**
393 * @ingroup los_task
394 * Task error code: The task delay occurs in software timer task.
395 *
396 * Value: 0x03000222
397 *
398 * Solution: Don't call Los_TaskDelay in software timer callback.
399 */
400#define LOS_ERRNO_TSK_DELAY_IN_SWTMR_TSK LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x22)
401
402/**
403 * @ingroup los_task
404 * Task error code: The cpu affinity mask is incorrect.
405 *
406 * Value: 0x03000223
407 *
408 * Solution: Please set the correct cpu affinity mask.
409 */
410#define LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x23)
411
412/**
413 * @ingroup los_task
414 * Task error code: Task yeild in int is not permited, which will result in unexpected result.
415 *
416 * Value: 0x02000224
417 *
418 * Solution: Don't call LOS_TaskYield in Interrupt.
419 */
420#define LOS_ERRNO_TSK_YIELD_IN_INT LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x24)
421
422/**
423* @ingroup los_task
424* Task error code: Task sync resource (semaphore) allocated failed.
425*
426* Value: 0x02000225
427*
428* Solution: Expand LOSCFG_BASE_IPC_SEM_LIMIT.
429*/
430#define LOS_ERRNO_TSK_MP_SYNC_RESOURCE LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x25)
431
432/**
433* @ingroup los_task
434* Task error code: Task sync failed on operating running task across cores.
435*
436* Value: 0x02000226
437*
438* Solution: Check task delete can be handled in user's scenario.
439*/ //跨核心运行任务时任务同步失败,检查任务删除可以在用户场景中处理
440#define LOS_ERRNO_TSK_MP_SYNC_FAILED LOS_ERRNO_OS_ERROR(LOS_MOD_TSK, 0x26)
441
442/**
443* @ingroup los_task
444* Task error code: Task wait and timeout.
445*
446* Value: 0x02000227
447*
448* Solution: Returns the timeout.
449*/
450#define LOS_ERRNO_TSK_TIMEOUT LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x27)
451
452/**
453* @ingroup los_task
454* Task error code: A task that is not in the current process.
455*
456* Value: 0x02000228
457*
458* Solution: tasks that are not part of the current process are not allowed to operate.
459*/
460#define LOS_ERRNO_TSK_NOT_SELF_PROCESS LOS_ERRNO_OS_FATAL(LOS_MOD_TSK, 0x28)
461
462/**
463* @ingroup los_task
464* @brief Define the type of a task entrance function.
465*
466* @par Description:
467* This API is used to define the type of a task entrance function and call it after a task is created and triggered.
468* @attention None.
469*
470* @param param1 [IN] Type #UINTPTR The first parameter passed to the task handling function.
471* @param param2 [IN] Type #UINTPTR The second parameter passed to the task handling function.
472* @param param3 [IN] Type #UINTPTR The third parameter passed to the task handling function.
473* @param param4 [IN] Type #UINTPTR The fourth parameter passed to the task handling function.
474*
475* @retval None.
476* @par Dependency:
477* <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
478* @see
479*/
480typedef VOID *(*TSK_ENTRY_FUNC)(UINTPTR param1,
481 UINTPTR param2,
482 UINTPTR param3,
483 UINTPTR param4);
484
485/**
486 * @ingroup los_task
487 * You are not allowed to add any fields and adjust fields to the structure
488 | 不允许在结构中添加任何字段和调整字段 @note_thinking 为什么呢 ?
489 */
490typedef struct {//用户态栈信息,(按递减满栈方式注解)
491 UINTPTR userArea; ///< 用户空间的堆区开始位置
492 UINTPTR userSP; ///< 用户空间当前栈指针位置
493 UINTPTR userMapBase;///< 用户空间的栈顶位置.
494 UINT32 userMapSize;///< 用户空间的栈大小,栈底 = userMapBase + userMapSize
496
497/**
498 * @ingroup los_task
499 * Define the structure of the parameters used for task creation.
500 *
501 * Information of specified parameters passed in during task creation.
502 */
503typedef struct tagTskInitParam {//Task的初始化参数
504 TSK_ENTRY_FUNC pfnTaskEntry; /**< Task entrance function | 任务的入口函数*/
505 UINT16 usTaskPrio; /**< Task priority | 任务优先级*/
506 UINT16 policy; /**< Task policy | 任务调度方式*/
507 UINTPTR auwArgs[4]; /**< Task parameters, of which the maximum number is four | 入口函数的参数,最多四个*/
508 UINT32 uwStackSize; /**< Task stack size | 栈大小*/
509 CHAR *pcName; /**< Task name | 任务名称*/
510#ifdef LOSCFG_KERNEL_SMP
511 UINT16 usCpuAffiMask; /**< Task cpu affinity mask | 任务cpu亲和力掩码 */
512#endif
513 UINT32 uwResved; /**< It is automatically deleted if set to LOS_TASK_STATUS_DETACHED.
514 It is unable to be deleted if set to 0. | 如果设置为LOS_TASK_STATUS_DETACHED,则自动删除。如果设置为0,则无法删除*/
515 UINT16 consoleID; /**< The console id of task belongs | 任务的控制台id所属*/
516 UINT32 processID; ///< 进程ID
517 UserTaskParam userParam; ///< 任务用户态运行时任何参数
519
520/**
521 * @ingroup los_task
522 * Task name length
523 *
524 */
525#define LOS_TASK_NAMELEN 32
526
527/**
528 * @ingroup los_task
529 * Task information structure.
530 *
531 */
532typedef struct tagTskInfo { //主要用于 shell task -a 使用
533 CHAR acName[LOS_TASK_NAMELEN]; /**< Task entrance function */
534 UINT32 uwTaskID; /**< Task ID */
535 UINT16 usTaskStatus; /**< Task status */
536 UINT16 usTaskPrio; /**< Task priority */
537 VOID *pTaskSem; /**< Semaphore pointer */
538 VOID *pTaskMux; /**< Mutex pointer */
539 VOID *taskEvent; /**< Event */
540 UINT32 uwEventMask; /**< Event mask */
541 UINT32 uwStackSize; /**< Task stack size */
542 UINTPTR uwTopOfStack; /**< Task stack top */
543 UINTPTR uwBottomOfStack; /**< Task stack bottom */
544 UINTPTR uwSP; /**< Task SP pointer */
545 UINT32 uwCurrUsed; /**< Current task stack usage */
546 UINT32 uwPeakUsed; /**< Task stack usage peak */
547 BOOL bOvf; /**< Flag that indicates whether a task stack overflow occurs */
549
550/**
551 * @ingroup los_task
552 * @brief Create a task and suspend.
553 *
554 * @par Description:
555 * This API is used to create a task and suspend it. This task will not be added to the queue of ready tasks
556 * before resume it.
557 *
558 * @attention
559 * <ul>
560 * <li>During task creation, the task control block and task stack of the task that is previously automatically deleted
561 * are deallocated.</li>
562 * <li>The task name is a pointer and is not allocated memory.</li>
563 * <li>If the size of the task stack of the task to be created is 0, configure #LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE
564 * to specify the default task stack size. The stack size should be a reasonable value, if the size is too large, may
565 * cause memory exhaustion.</li>
566 * <li>The task stack size must be aligned on the boundary of 8 bytes. The size is determined by whether it is big
567 * enough to avoid task stack overflow.</li>
568 * <li>Less parameter value indicates higher task priority.</li>
569 * <li>The task name cannot be null.</li>
570 * <li>The pointer to the task executing function cannot be null.</li>
571 * <li>The two parameters of this interface is pointer, it should be a correct value, otherwise, the system may be
572 * abnormal.</li>
573 * </ul>
574 *
575 * @param taskID [OUT] Type #UINT32 * Task ID.
576 * @param initParam [IN] Type #TSK_INIT_PARAM_S * Parameter for task creation.
577 *
578 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID, param taskID is NULL.
579 * @retval #LOS_ERRNO_TSK_PTR_NULL Param initParam is NULL.
580 * @retval #LOS_ERRNO_TSK_NAME_EMPTY The task name is NULL.
581 * @retval #LOS_ERRNO_TSK_ENTRY_NULL The task entrance is NULL.
582 * @retval #LOS_ERRNO_TSK_PRIOR_ERROR Incorrect task priority.
583 * @retval #LOS_ERRNO_TSK_STKSZ_TOO_LARGE The task stack size is too large.
584 * @retval #LOS_ERRNO_TSK_STKSZ_TOO_SMALL The task stack size is too small.
585 * @retval #LOS_ERRNO_TSK_TCB_UNAVAILABLE No free task control block is available.
586 * @retval #LOS_ERRNO_TSK_NO_MEMORY Insufficient memory for task creation.
587 * @retval #LOS_OK The task is successfully created.
588 * @par Dependency:
589 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
590 * <ul><li>los_config.h: the header file that contains system configuration items.</li></ul>
591 * @see LOS_TaskDelete
592 */
593extern UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S *initParam);
594
595/**
596 * @ingroup los_task
597 * @brief Create a task.
598 *
599 * @par Description:
600 * This API is used to create a task. If the priority of the task created after system initialized is higher than
601 * the current task and task scheduling is not locked, it is scheduled for running.
602 * If not, the created task is added to the queue of ready tasks.
603 *
604 * @attention
605 * <ul>
606 * <li>During task creation, the task control block and task stack of the task that is previously automatically
607 * deleted are deallocated.</li>
608 * <li>The task name is a pointer and is not allocated memory.</li>
609 * <li>If the size of the task stack of the task to be created is 0, configure #LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE
610 * to specify the default task stack size.</li>
611 * <li>The task stack size must be aligned on the boundary of 8 bytes. The size is determined by whether it is big
612 * enough to avoid task stack overflow.</li>
613 * <li>Less parameter value indicates higher task priority.</li>
614 * <li>The task name cannot be null.</li>
615 * <li>The pointer to the task executing function cannot be null.</li>
616 * <li>The two parameters of this interface is pointer, it should be a correct value, otherwise, the system may be
617 * abnormal.</li>
618 * </ul>
619 *
620 * @param taskID [OUT] Type #UINT32 * Task ID.
621 * @param initParam [IN] Type #TSK_INIT_PARAM_S * Parameter for task creation.
622 *
623 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID, param taskID is NULL.
624 * @retval #LOS_ERRNO_TSK_PTR_NULL Param initParam is NULL.
625 * @retval #LOS_ERRNO_TSK_NAME_EMPTY The task name is NULL.
626 * @retval #LOS_ERRNO_TSK_ENTRY_NULL The task entrance is NULL.
627 * @retval #LOS_ERRNO_TSK_PRIOR_ERROR Incorrect task priority.
628 * @retval #LOS_ERRNO_TSK_STKSZ_TOO_LARGE The task stack size is too large.
629 * @retval #LOS_ERRNO_TSK_STKSZ_TOO_SMALL The task stack size is too small.
630 * @retval #LOS_ERRNO_TSK_TCB_UNAVAILABLE No free task control block is available.
631 * @retval #LOS_ERRNO_TSK_NO_MEMORY Insufficient memory for task creation.
632 * @retval #LOS_OK The task is successfully created.
633 * @par Dependency:
634 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
635 * <ul><li>los_config.h: the header file that contains system configuration items.</li></ul>
636 * @see LOS_TaskDelete
637 */
638extern UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *initParam);
639
640/**
641 * @ingroup los_task
642 * @brief Resume a task.
643 *
644 * @par Description:
645 * This API is used to resume a suspended task.
646 *
647 * @attention
648 * <ul>
649 * <li>If the task is delayed or blocked, resume the task without adding it to the queue of ready tasks.</li>
650 * <li>If the priority of the task resumed after system initialized is higher than the current task and task scheduling
651 * is not locked, it is scheduled for running.</li>
652 * </ul>
653 *
654 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
655 *
656 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
657 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
658 * @retval #LOS_ERRNO_TSK_NOT_SUSPENDED The task is not suspended.
659 * @retval #LOS_OK The task is successfully resumed.
660 * @par Dependency:
661 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
662 * @see LOS_TaskSuspend
663 */
664extern UINT32 LOS_TaskResume(UINT32 taskID);
665
666/**
667 * @ingroup los_task
668 * @brief Suspend a task.
669 *
670 * @par Description:
671 * This API is used to suspend a specified task, and the task will be removed from the queue of ready tasks.
672 *
673 * @attention
674 * <ul>
675 * <li>The task that is running and locked cannot be suspended.</li>
676 * <li>The idle task and swtmr task cannot be suspended.</li>
677 * </ul>
678 *
679 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
680 *
681 * @retval #LOS_ERRNO_TSK_OPERATE_IDLE Check the task ID and do not operate on the idle task.
682 * @retval #LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED Check the task ID and do not operate on the swtmr task.
683 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
684 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
685 * @retval #LOS_ERRNO_TSK_ALREADY_SUSPENDED The task is already suspended.
686 * @retval #LOS_ERRNO_TSK_SUSPEND_LOCKED The task being suspended is current task and task scheduling
687 * is locked.
688 * @retval #LOS_OK The task is successfully suspended.
689 * @par Dependency:
690 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
691 * @see LOS_TaskResume
692 */
693extern UINT32 LOS_TaskSuspend(UINT32 taskID);
694
695/**
696 * @ingroup los_task
697 * @brief Delete a task.
698 *
699 * @par Description:
700 * This API is used to delete a specified task and release the resources for its task stack and task control block.
701 *
702 * @attention
703 * <ul>
704 * <li>The idle task and swtmr task cannot be deleted.</li>
705 * <li>If delete current task maybe cause unexpected error.</li>
706 * <li>If a task get a mutex is deleted or automatically deleted before release this mutex, other tasks pended
707 * this mutex maybe never be shchduled.</li>
708 * </ul>
709 *
710 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
711 *
712 * @retval #LOS_ERRNO_TSK_OPERATE_IDLE Check the task ID and do not operate on the idle task.
713 * @retval #LOS_ERRNO_TSK_SUSPEND_SWTMR_NOT_ALLOWED Check the task ID and do not operate on the swtmr task.
714 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
715 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
716 * @retval #LOS_ERRNO_TSK_DELETE_LOCKED The task being deleted is current task and task scheduling
717 * is locked.
718 * @retval #LOS_OK The task is successfully deleted.
719 * @par Dependency:
720 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
721 * @see LOS_TaskCreate | LOS_TaskCreateOnly
722 */
723extern UINT32 LOS_TaskDelete(UINT32 taskID);
724
725/**
726 * @ingroup los_task
727 * @brief Delay a task.
728 *
729 * @par Description:
730 * This API is used to delay the execution of the current task. The task is able to be scheduled after it is delayed
731 * for a specified number of Ticks.
732 *
733 * @attention
734 * <ul>
735 * <li>The task fails to be delayed if it is being delayed during interrupt processing or it is locked.</li>
736 * <li>If 0 is passed in and the task scheduling is not locked, execute the next task in the queue of tasks with
737 * the same priority of the current task.
738 * If no ready task with the priority of the current task is available, the task scheduling will not occur, and the
739 * current task continues to be executed.</li>
740 * <li>Using the interface before system initialized is not allowed.</li>
741 * <li>DO NOT call this API in software timer callback. </li>
742 * </ul>
743 *
744 * @param tick [IN] Type #UINT32 Number of Ticks for which the task is delayed.
745 *
746 * @retval #LOS_ERRNO_TSK_DELAY_IN_INT The task delay occurs during an interrupt.
747 * @retval #LOS_ERRNO_TSK_DELAY_IN_LOCK The task delay occurs when the task scheduling is locked.
748 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
749 * @retval #LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK No tasks with the same priority is available for scheduling.
750 * @retval #LOS_OK The task is successfully delayed.
751 * @par Dependency:
752 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
753 * @see
754 */
755extern UINT32 LOS_TaskDelay(UINT32 tick);
756
757/**
758 * @ingroup los_task
759 * @brief Lock the task scheduling.
760 *
761 * @par Description:
762 * This API is used to lock the task scheduling. Task switching will not occur if the task scheduling is locked.
763 *
764 * @attention
765 * <ul>
766 * <li>If the task scheduling is locked, but interrupts are not disabled, tasks are still able to be interrupted.</li>
767 * <li>One is added to the number of task scheduling locks if this API is called. The number of locks is decreased by
768 * one if the task scheduling is unlocked. Therefore, this API should be used together with LOS_TaskUnlock.</li>
769 * </ul>
770 *
771 * @param None.
772 *
773 * @retval None.
774 * @par Dependency:
775 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
776 * @see LOS_TaskUnlock
777 */
778extern VOID LOS_TaskLock(VOID);
779
780/**
781 * @ingroup los_task
782 * @brief Unlock the task scheduling.
783 *
784 * @par Description:
785 * This API is used to unlock the task scheduling. Calling this API will decrease the number of task locks by one.
786 * If a task is locked more than once, the task scheduling will be unlocked only when the number of locks becomes zero.
787 *
788 * @attention
789 * <ul>
790 * <li>The number of locks is decreased by one if this API is called. One is added to the number of task scheduling
791 * locks if the task scheduling is locked. Therefore, this API should be used together with LOS_TaskLock.</li>
792 * </ul>
793 *
794 * @param None.
795 *
796 * @retval None.
797 * @par Dependency:
798 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
799 * @see LOS_TaskLock
800 */
801extern VOID LOS_TaskUnlock(VOID);
802
803/**
804 * @ingroup los_task
805 * @brief Set a task priority.
806 *
807 * @par Description:
808 * This API is used to set the priority of a specified task.
809 *
810 * @attention
811 * <ul>
812 * <li>If the set priority is higher than the priority of the current running task, task scheduling
813 * probably occurs.</li>
814 * <li>Changing the priority of the current running task also probably causes task scheduling.</li>
815 * <li>Using the interface to change the priority of software timer task and idle task is not allowed.</li>
816 * <li>Using the interface in the interrupt is not allowed.</li>
817 * </ul>
818 *
819 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
820 * @param taskPrio [IN] Type #UINT16 Task priority.
821 *
822 * @retval #LOS_ERRNO_TSK_PRIOR_ERROR Incorrect task priority.Re-configure the task priority
823 * @retval #LOS_ERRNO_TSK_OPERATE_IDLE Check the task ID and do not operate on the idle task.
824 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
825 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
826 * @retval #LOS_OK The task priority is successfully set to a specified priority.
827 * @par Dependency:
828 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
829 * @see LOS_TaskPriSet
830 */
831extern UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio);
832
833/**
834 * @ingroup los_task
835 * @brief Set the priority of the current running task to a specified priority.
836 *
837 * @par Description:
838 * This API is used to set the priority of the current running task to a specified priority.
839 *
840 * @attention
841 * <ul>
842 * <li>Changing the priority of the current running task probably causes task scheduling.</li>
843 * <li>Using the interface to change the priority of software timer task and idle task is not allowed.</li>
844 * <li>Using the interface in the interrupt is not allowed.</li>
845 * </ul>
846 *
847 * @param taskPrio [IN] Type #UINT16 Task priority.
848 *
849 * @retval #LOS_ERRNO_TSK_PRIOR_ERROR Incorrect task priority.Re-configure the task priority
850 * @retval #LOS_ERRNO_TSK_OPERATE_IDLE Check the task ID and do not operate on the idle task.
851 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
852 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
853 * @retval #LOS_OK The priority of the current running task is successfully set to a specified
854 * priority.
855 * @par Dependency:
856 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
857 * @see LOS_TaskPriGet
858 */
859extern UINT32 LOS_CurTaskPriSet(UINT16 taskPrio);
860
861/**
862 * @ingroup los_task
863 * @brief Change the scheduling sequence of tasks with the same priority.
864 *
865 * @par Description:
866 * This API is used to move current task in a queue of tasks with the same priority to the tail of the queue of ready
867 * tasks.
868 *
869 * @attention
870 * <ul>
871 * <li>At least two ready tasks need to be included in the queue of ready tasks with the same priority. If the
872 * less than two ready tasks are included in the queue, an error is reported.</li>
873 * </ul>
874 *
875 * @param None.
876 *
877 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID
878 * @retval #LOS_ERRNO_TSK_YIELD_NOT_ENOUGH_TASK No tasks with the same priority is available for scheduling.
879 * @retval #LOS_OK The scheduling sequence of tasks with same priority is
880 * successfully changed.
881 * @par Dependency:
882 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
883 * @see
884 */
885extern UINT32 LOS_TaskYield(VOID);
886
887/**
888 * @ingroup los_task
889 * @brief Obtain a task priority.
890 *
891 * @par Description:
892 * This API is used to obtain the priority of a specified task.
893 *
894 * @attention None.
895 *
896 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
897 *
898 * @retval #OS_INVALID The task priority fails to be obtained.
899 * @retval #UINT16 The task priority.
900 * @par Dependency:
901 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
902 * @see LOS_TaskPriSet
903 */
904extern UINT16 LOS_TaskPriGet(UINT32 taskID);
905
906/**
907 * @ingroup los_task
908 * @brief Obtain current running task ID.
909 *
910 * @par Description:
911 * This API is used to obtain the ID of current running task.
912 *
913 * @attention
914 * <ul>
915 * <li> This interface should not be called before system initialized.</li>
916 * </ul>
917 *
918 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid Task ID.
919 * @retval #UINT32 Task ID.
920 * @par Dependency:
921 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
922 * @see
923 */
924extern UINT32 LOS_CurTaskIDGet(VOID);
925
926/**
927 * @ingroup los_task
928 * @brief Gets the maximum number of threads supported by the system.
929 *
930 * @par Description:
931 * This API is used to gets the maximum number of threads supported by the system.
932 *
933 * @attention
934 * <ul>
935 * <li> This interface should not be called before system initialized.</li>
936 * </ul>
937 *
938 * @retval None.
939 * @par Dependency:
940 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
941 * @see
942 */
944
945/**
946 * @ingroup los_task
947 * @brief Obtain a task information structure.
948 *
949 * @par Description:
950 * This API is used to obtain a task information structure.
951 *
952 * @attention
953 * <ul>
954 * <li>One parameter of this interface is a pointer, it should be a correct value, otherwise, the system may be
955 * abnormal.</li>
956 * </ul>
957 *
958 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
959 * @param taskInfo [OUT] Type #TSK_INFO_S* Pointer to the task information structure to be obtained.
960 *
961 * @retval #LOS_ERRNO_TSK_PTR_NULL Null parameter.
962 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid task ID.
963 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
964 * @retval #LOS_OK The task information structure is successfully obtained.
965 * @par Dependency:
966 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
967 * @see
968 */
969extern UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInfo);
970
971
972/**
973 * @ingroup los_task
974 * @brief Set the affinity mask of the task scheduling cpu.
975 *
976 * @par Description:
977 * This API is used to set the affinity mask of the task scheduling cpu.
978 *
979 * @attention
980 * <ul>
981 * <li>If any low LOSCFG_KERNEL_CORE_NUM bit of the mask is not setted, an error is reported.</li>
982 * </ul>
983 *
984 * @param uwTaskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
985 * @param usCpuAffiMask [IN] Type #UINT32 The scheduling cpu mask.The low to high bit of the mask corresponds to
986 * the cpu number, the high bit that exceeding the CPU number is ignored.
987 *
988 * @retval #LOS_ERRNO_TSK_ID_INVALID Invalid task ID.
989 * @retval #LOS_ERRNO_TSK_NOT_CREATED The task is not created.
990 * @retval #LOS_ERRNO_TSK_CPU_AFFINITY_MASK_ERR The task cpu affinity mask is incorrect.
991 * @retval #LOS_OK The task cpu affinity mask is successfully setted.
992 * @par Dependency:
993 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
994 * @see LOS_TaskCpuAffiGet
995 */
996extern UINT32 LOS_TaskCpuAffiSet(UINT32 uwTaskID, UINT16 usCpuAffiMask);
997
998/**
999 * @ingroup los_task
1000 * @brief Get the affinity mask of the task scheduling cpu.
1001 *
1002 * @par Description:
1003 * This API is used to get the affinity mask of the task scheduling cpu.
1004 *
1005 * @attention None.
1006 *
1007 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
1008 *
1009 * @retval #0 The cpu affinity mask fails to be obtained.
1010 * @retval #UINT16 The scheduling cpu mask. The low to high bit of the mask corresponds to the cpu number.
1011 * @par Dependency:
1012 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1013 * @see LOS_TaskCpuAffiSet
1014 */
1015extern UINT16 LOS_TaskCpuAffiGet(UINT32 taskID);
1016
1017/**
1018 * @ingroup los_task
1019 * @brief Get the scheduling policy for the task.
1020 *
1021 * @par Description:
1022 * This API is used to get the scheduling policy for the task.
1023 *
1024 * @attention None.
1025 *
1026 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
1027 *
1028 * @retval #-LOS_ESRCH Invalid task id.
1029 * @retval #-LOS_EPERM The process is not currently running.
1030 * @retval #INT32 the scheduling policy.
1031 * @par Dependency:
1032 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1033 * @see LOS_SetTaskScheduler
1034 */
1035extern INT32 LOS_GetTaskScheduler(INT32 taskID);
1036
1037/**
1038 * @ingroup los_task
1039 * @brief Set the scheduling policy and priority for the task.
1040 *
1041 * @par Description:
1042 * This API is used to set the scheduling policy and priority for the task.
1043 *
1044 * @attention None.
1045 *
1046 * @param taskID [IN] Type #UINT32 Task ID. The task id value is obtained from task creation.
1047 * @param policy [IN] Type #UINT16 Task scheduling policy.
1048 * @param priority [IN] Type #UINT16 Task scheduling priority.
1049 *
1050 * @retval -LOS_ESRCH Invalid task id.
1051 * @retval -LOS_EOPNOTSUPP Unsupported fields.
1052 * @retval -LOS_EPERM The process is not currently running.
1053 * @retval #0 Set up the success.
1054 * @par Dependency:
1055 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1056 * @see LOS_GetTaskScheduler
1057 */
1058extern INT32 LOS_SetTaskScheduler(INT32 taskID, UINT16 policy, UINT16 priority);
1059
1060/**
1061 * @ingroup los_task
1062 * @brief Trigger active task scheduling.
1063 *
1064 * @par Description:
1065 * This API is used to trigger active task scheduling.
1066 *
1067 * @attention None.
1068 *
1069 * @param None
1070 *
1071 * @retval Nobe
1072 * @par Dependency:
1073 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1074 */
1075extern VOID LOS_Schedule(VOID);
1076
1077/**
1078 * @ingroup los_task
1079 * @brief Wait for the specified task to finish and reclaim its resources.
1080 *
1081 * @par Description:
1082 * This API is used to wait for the specified task to finish and reclaim its resources.
1083 *
1084 * @attention None.
1085 *
1086 * @param taskID [IN] task ID.
1087 * @param retval [OUT] wait for the return value of the task.
1088 *
1089 * @retval LOS_OK successful
1090 * @retval LOS_EINVAL Invalid parameter or invalid operation
1091 * @retval LOS_EINTR Disallow calls in interrupt handlers
1092 * @retval LOS_EPERM Waiting tasks and calling tasks do not belong to the same process
1093 * @retval LOS_EDEADLK The waiting task is the same as the calling task
1094 * @par Dependency:
1095 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1096 */
1097extern UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval);
1098
1099/**
1100 * @ingroup los_task
1101 * @brief Change the joinable attribute of the task to detach.
1102 *
1103 * @par Description:
1104 * This API is used to change the joinable attribute of the task to detach.
1105 *
1106 * @attention None.
1107 *
1108 * @param taskID [IN] task ID.
1109 *
1110 * @retval LOS_OK successful
1111 * @retval LOS_EINVAL Invalid parameter or invalid operation
1112 * @retval LOS_EINTR Disallow calls in interrupt handlers
1113 * @retval LOS_EPERM Waiting tasks and calling tasks do not belong to the same process
1114 * @retval LOS_ESRCH Cannot modify the Joinable attribute of a task that is waiting for completion.
1115 * @par Dependency:
1116 * <ul><li>los_task.h: the header file that contains the API declaration.</li></ul>
1117 */
1118extern UINT32 LOS_TaskDetach(UINT32 taskID);
1119
1120#ifdef __cplusplus
1121#if __cplusplus
1122}
1123#endif /* __cplusplus */
1124#endif /* __cplusplus */
1125
1126#endif /* _LOS_TASK_H */
UINT32 LOS_TaskCpuAffiSet(UINT32 uwTaskID, UINT16 usCpuAffiMask)
Set the affinity mask of the task scheduling cpu.
Definition: los_task.c:1231
VOID LOS_TaskUnlock(VOID)
Unlock the task scheduling.
Definition: los_task.c:1148
UINT32 LOS_TaskDelete(UINT32 taskID)
Delete a task.
Definition: los_task.c:968
UINT32 LOS_CurTaskPriSet(UINT16 taskPrio)
Set the priority of the current running task to a specified priority.
Definition: los_task.c:1109
UINT32 LOS_TaskResume(UINT32 taskID)
Resume a task.
Definition: los_task.c:758
UINT32 LOS_TaskDetach(UINT32 taskID)
Change the joinable attribute of the task to detach.
Definition: los_task.c:1601
UINT32 LOS_CurTaskIDGet(VOID)
Obtain current running task ID.
Definition: los_task.c:331
UINT32 LOS_GetSystemTaskMaximum(VOID)
Gets the maximum number of threads supported by the system.
Definition: los_task.c:1637
UINT16 LOS_TaskPriGet(UINT32 taskID)
Obtain a task priority.
Definition: los_task.c:1050
UINT32 LOS_TaskYield(VOID)
Change the scheduling sequence of tasks with the same priority.
Definition: los_task.c:1115
UINT32 LOS_TaskPriSet(UINT32 taskID, UINT16 taskPrio)
Set a task priority.
Definition: los_task.c:1071
INT32 LOS_GetTaskScheduler(INT32 taskID)
Get the scheduling policy for the task.
Definition: los_task.c:1467
UINT32 LOS_TaskCreateOnly(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
Create a task and suspend.
Definition: los_task.c:663
INT32 LOS_SetTaskScheduler(INT32 taskID, UINT16 policy, UINT16 priority)
Set the scheduling policy and priority for the task.
Definition: los_task.c:1493
struct tagTskInitParam TSK_INIT_PARAM_S
UINT32 LOS_TaskSuspend(UINT32 taskID)
Suspend a task.
Definition: los_task.c:855
VOID LOS_TaskLock(VOID)
Lock the task scheduling.
Definition: los_task.c:1139
UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *initParam)
Create a task.
Definition: los_task.c:718
VOID LOS_Schedule(VOID)
Trigger active task scheduling.
Definition: los_sched.c:469
UINT32 LOS_TaskDelay(UINT32 tick)
Delay a task.
Definition: los_task.c:1020
UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInfo)
Obtain a task information structure.
Definition: los_task.c:1161
struct tagTskInfo TSK_INFO_S
VOID *(* TSK_ENTRY_FUNC)(UINTPTR param1, UINTPTR param2, UINTPTR param3, UINTPTR param4)
Define the type of a task entrance function.
Definition: los_task.h:480
UINT32 LOS_TaskJoin(UINT32 taskID, UINTPTR *retval)
Wait for the specified task to finish and reclaim its resources.
Definition: los_task.c:1561
UINT16 LOS_TaskCpuAffiGet(UINT32 taskID)
Get the affinity mask of the task scheduling cpu.
Definition: los_task.c:1263
双向链表由内联函数实现 http://weharmonyos.com/openharmony/zh-cn/device-dev/kernel/kernel-small-apx-dll....
unsigned short UINT16
Definition: los_typedef.h:56
signed int INT32
Definition: los_typedef.h:60
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
char CHAR
Definition: los_typedef.h:63
size_t BOOL
Definition: los_typedef.h:88
UINT32 userMapSize
用户空间的栈大小,栈底 = userMapBase + userMapSize
Definition: los_task.h:494
UINTPTR userArea
用户空间的堆区开始位置
Definition: los_task.h:491
UINTPTR userMapBase
用户空间的栈顶位置.
Definition: los_task.h:493
UINTPTR userSP
用户空间当前栈指针位置
Definition: los_task.h:492
UINT16 usTaskPrio
Definition: los_task.h:536
UINT16 usTaskStatus
Definition: los_task.h:535
UINT32 uwStackSize
Definition: los_task.h:541
UINTPTR uwBottomOfStack
Definition: los_task.h:543
VOID * pTaskMux
Definition: los_task.h:538
UINT32 uwPeakUsed
Definition: los_task.h:546
UINT32 uwTaskID
Definition: los_task.h:534
UINTPTR uwSP
Definition: los_task.h:544
UINT32 uwCurrUsed
Definition: los_task.h:545
BOOL bOvf
Definition: los_task.h:547
CHAR acName[LOS_TASK_NAMELEN]
Definition: los_task.h:533
UINTPTR uwTopOfStack
Definition: los_task.h:542
UINT32 uwEventMask
Definition: los_task.h:540
VOID * taskEvent
Definition: los_task.h:539
VOID * pTaskSem
Definition: los_task.h:537
UINT16 policy
Definition: los_task.h:506
UINT16 usTaskPrio
Definition: los_task.h:505
UINTPTR auwArgs[4]
Definition: los_task.h:507
UINT16 usCpuAffiMask
Definition: los_task.h:511
UINT32 uwStackSize
Definition: los_task.h:508
CHAR * pcName
Definition: los_task.h:509
UINT32 processID
进程ID
Definition: los_task.h:516
TSK_ENTRY_FUNC pfnTaskEntry
Definition: los_task.h:504
UserTaskParam userParam
任务用户态运行时任何参数
Definition: los_task.h:517
UINT32 uwResved
Definition: los_task.h:513
UINT16 consoleID
Definition: los_task.h:515