Task Creation Routines
-
-
|
Call |
Description |
|
taskSpawn( ) |
Spawns (creates and activates) a new task. |
taskInit( ) |
Initializes a new task. |
taskActivate( ) |
Activates an initialized task. |
|
Vxworks 创建一个任务和Linux下创建一个进程有点类似,
id = taskSpawn (name, priority, options, stacksize, main, arg1, arg10 );
tid = taskSpawn ("tMyTask", 90, VX_FP_TASK, 20000, myFunc, 2387, 0, 0, 0, 0, 0, 0, 0, 0, 0);
只不过在Linux 下创建一个进程是不需要用户为其分配空间,系统会自动为其分配空间,而Vxworks需要为创建的任务分派相应的堆栈空间来运行这个任务,一般很难很准确的为任务分派大小合适的空间,不过我们可以周期性的检测我们分派的堆栈空间是否有过大过小的问题来动态调整其空间大小。
一般使用: checkStack() 来监控我们分派的空间。
|
Task Option Routines
-
-
|
Call |
Description |
|
taskOptionsGet( ) |
Examines task options. |
taskOptionsSet( ) |
Sets task options. |
|
- 5、Task Information (任务的相关信息)
Task Information Routines
-
-
|
Call |
Description |
|
taskIdListGet( ) |
Fills an array with the IDs of all active tasks. |
taskInfoGet( ) |
Gets information about a task. |
taskPriority( ) |
Examines the priority of a task. |
taskRegsGet( ) |
Examines a task's registers (cannot be used with the current task). |
taskRegsSet( ) |
Sets a task's registers (cannot be used with the current task). |
taskIsSuspend ( ) |
Checks whether a task is suspended. |
taskIsReady( ) |
Checks whether a task is ready to run. |
taskTcb( ) |
Gets a pointer to a task's control block.
|
|
- 6、Task Deletion and Deletion Safety (任务的删除)
在Vxworks系统中我们可以动态的删除一个任务,当然系统也提供一些保护措施以防止意外删除造成不可预知的结果。
Task-Deletion Routines
-
-
|
Call |
Description |
|
exit( ) |
Terminates the calling task and frees memory (task stacks and task control blocks only).1 |
taskDel( ) |
Terminates a specified task and frees memory (task stacks and task control blocks only).* |
taskSafe( ) |
Protects the calling task from deletion. |
taskUnsaf( ) |
Undoes a taskSafe( ) (makes the calling task available for deletion). |
| NOTE: You can use VxWorks events to send an event when a task finishes executing. For more information, see :
-
- 7、 Task Control (任务控制)
Task Control Routines
-
-
|
Call |
Description |
|
taskSuspend( ) |
Suspends a task. |
taskResume( ) |
Resumes a task. |
taskRestart( ) |
Restarts a task. |
taskDelay( ) |
Delays a task; delay units are ticks, resolution in ticks. |
nanosleep( ) |
Delays a task; delay units are nanoseconds, resolution in ticks. |
| |