Another Question,For Tele-op, we have programmed the robot so that there are 5 tasks running the robot; task main, driveTask, ballCollectionTask, ballDispensionTask, and goalGrabbingTask. This all works great.

My question is, does it matter if there are waits inside of each task? My understanding is that this would release the CPU for a few hundredths of a second. Does that help improve the efficiency of the program overall and improve response time between the robot and joystick?

_________________FTC 7104 - The Synergists

Mon Jan 12, 2015 12:43 am

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: Multitasking and Waits

Synergists wrote:

Another Question,For Tele-op, we have programmed the robot so that there are 5 tasks running the robot; task main, driveTask, ballCollectionTask, ballDispensionTask, and goalGrabbingTask. This all works great.

My question is, does it matter if there are waits inside of each task? My understanding is that this would release the CPU for a few hundredths of a second. Does that help improve the efficiency of the program overall and improve response time between the robot and joystick?

If these are RobotC tasks, then sure you can have wait statements in each of the tasks. The RobotC VM will take care of switching the CPU between different tasks. However, you must be very careful on what you access in each tasks. If these tasks share common resources, there may be contentions. For example, if a group of global variables is referenced by a task, they might be changed by another task right in the middle of the access. It is especially bad if this group of variables could be gotten into an inconsistent state during task switching. That's why you may need to do hogCPU and releaseCPU to protect a section of code that is referencing a group of variables that are related to each other. If you are not familiar with the concept of preemptive multi-tasking, you may want to avoid using tasks.

Mon Jan 12, 2015 3:25 am

Synergists

Rookie

Joined: Mon Dec 15, 2014 12:46 amPosts: 19

Re: Multitasking and Waits

Thanks! Both of those are good to know!

_________________FTC 7104 - The Synergists

Mon Jan 12, 2015 8:26 pm

FTC4592

Rookie

Joined: Tue Jan 21, 2014 8:41 pmPosts: 5

Re: Multitasking and Waits

Also something worth knowing is that you can use semaphores instead of hogCPU to protect variables without having to hogging the cpu for other tasks that don't use that variable.

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum