|
Page 1 of 1
|
[ 4 posts ] |
|
| Author |
Message |
|
tigran
Rookie
Joined: Wed Jan 31, 2007 7:11 am Posts: 4
|
 What does StartTask()?
What does StartTask() method?
What different between void Sub () and task Sub() ?
|
| Thu Feb 01, 2007 4:03 am |
|
 |
|
tfriez
Site Admin
Joined: Wed Jan 24, 2007 10:42 am Posts: 537
|
Void Sub() and Task Sub() are used to define different subroutines (tasks).
Task Control
Up to ten tasks can execute concurrently within a NXT user program. The ‘main’ or ‘primary’ task is automatically started when a user program is run. Execution of other tasks can be started and stopped with the ‘StartTask’ and ‘StopTask’ functions. The NXT will share CPU execution time among various tasks by giving each task a “time slice” where it will execute a group of instructions.
Each task can be assigned a priority from 0 to 255. The NXT scheduler gives execution time to the highest priority task that is waiting to run. A round robin scheduling scheme is used when there are multiple tasks ready to run all with the highest priority. Lower priority tasks will not execute until there are no tasks of higher priority that are ready to run.
A task that is waiting for a time period to expire is not ready to run. Once the time period has expired it will again become ready to run. Waiting tasks do not consume any CPU cycles.
nSchedulePriority
Variable containing the priority of the current task.
kDefaultPriority
Constant. The default priority assigned to a task.
kHighPriority
Constant. Highest priority that can be assigned to a task.
kLowPriority
Constant. Lowest priority that can be assigned to a task.
nCurrentTask
The numeric value for the current task.
nOpcodesPerTimeslice
Used to specify the size of an execution time slice before switching to another task. User should not normally have to modify this variable.
StartTask(TaskID);
Starts or restarts execution of the specified task.
StopAllTasks();
Stops execution of the current program.
StopTask(TaskID);
Stops execution of a single task.
EndTimeslice();
Immediately ends the current task time slice and allows another task to be immediately scheduled and executed.
_________________Timothy Friez ROBOTC Developer - SW Engineer tfriez@robotc.net
|
| Thu Feb 01, 2007 11:18 am |
|
 |
|
tigran
Rookie
Joined: Wed Jan 31, 2007 7:11 am Posts: 4
|
thank you
|
| Thu Feb 01, 2007 12:31 pm |
|
 |
|
Dick Swan
Creator
Joined: Fri Feb 09, 2007 9:21 am Posts: 613
|
A subroutinie/function can be called from within a program.
A "task" is like a "thread" or "process" in an operating system. It is a separate "stream of execution" and allows two activities to execute in parallel. As an example, consider a miltiary tank: You have one task to drive the tank. You have a second task to turn the turret and position the gun.
|
| Fri Feb 09, 2007 11:56 am |
|
|
|
Page 1 of 1
|
[ 4 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|