View unanswered posts | View active topics It is currently Mon Jan 22, 2018 10:12 pm






Reply to topic  [ 4 posts ] 
Multitasking and Waits 
Author Message
Rookie

Joined: Mon Dec 15, 2014 12:46 am
Posts: 19
Post Multitasking and Waits
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
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post 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
Profile
Rookie

Joined: Mon Dec 15, 2014 12:46 am
Posts: 19
Post Re: Multitasking and Waits
Thanks! Both of those are good to know!

_________________
FTC 7104 - The Synergists


Mon Jan 12, 2015 8:26 pm
Profile
Rookie

Joined: Tue Jan 21, 2014 8:41 pm
Posts: 5
Post 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.


Thu Mar 12, 2015 5:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 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

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.