Go to Post I personally think mentors should sit behind two-way mirrors and hold a kill switch for all power tools. ;) - SenorZ [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-02-2014, 18:21
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: Thread speed in C++

Quote:
Originally Posted by Joe Ross View Post
If you have to ask how fast a task executes, I question whether you can write sufficient examples.
Ouch. At the time I wrote the question, I didn't have access to the robot or the development environment, and was just hoping someone could tell me off the top of their head. I've since had access and figured it out on my own. We're only using it to isolate separate instances of our PID loops (for demonstration purposes), and our programming mentor and I deemed it's speed more than sufficient. We tested it using robot from last year and encoders to test running four consecutive loops on each of the independent drive motors (on blocks; not for driving purposes but to allow us to check and graph the speeds with a tachometer). I'll put up some graphs to show our results when I get the pictures off of the camera.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-02-2014, 23:59
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,169
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Thread speed in C++

Quote:
Originally Posted by ekapalka View Post
I'll put up some graphs to show our results when I get the pictures off of the camera.
That will be interesting to see. I think the point that persons in this thread are making is that "how fast is a task" is a verrrrry relative question. For example, I could code a simple task that ran in a tight loop and set the priority as great as possible (0 using the VxWorks native API or 99 using the Posix API). The speed of your task would be limited (only) by the throughput of the CPU, the nature of your code (does it all fit in cache, is it optimized etc) and what is going on in interrupt context. Of course nothing else in task context would ever run.

The real question (I think) is if we run at a priority that does not interfere with the operating system (exception handling, log messages etc) or the NI and WPI infrastructure (loaded when we image the robots, saftey and DS comms etc), what sort of performance might one expect. But even this measurement is relative - you might have a complex multi-tasking application where you are concerned about meeting periodic deadlines.

The "professional" way to handle this general question is to analyse all the code running on the robot. Google "rate monotonic analysis" - it is a widely used algorithm. The beauty of VxWorks (as opposed to Windoze) is if the analysis says you can meet all your timing parameters, the operating system will guarantee the performance. Make sense?

Of course in FIRST such an analysis might be impractical. So we run as many PID classes as we can, optimize the vision processing and pray. FIRST 1296 moved the vision processing to a Rasberry Pi and find that the cRIO can do most anything you ask if properly coded. In real-time programming there are a few time killers that programmers forgot most often - formatted print statements, memory allocation and long spinlocks can kill you. For this reason do NOT output stuff to the console in your normal (non-debug) modes of operation, allocate your memory as the robot powers up in an initialization phase and use proper operating system primitives (like mutual exclusion semaphores) to protect shared code or hardware. Also beware of C++ and Java - try to use constructors and templates that allocate memory up front and do not free and allocate memory in critical regions of your code.

HTH
__________________
Fast, cheap or working - pick any two!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi