Go to Post Of course 254 owns Battlebots too - dodar [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 04-21-2012, 10:14 PM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,002
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Multithreading and locking?

Quote:
Originally Posted by Skinkworks View Post
our team does't use any lock/semaphore-type structures, and we've never had a problem
Zera's Law: Once you realize that something bad can happen, it will.


Reply With Quote
  #2   Spotlight this post!  
Unread 04-22-2012, 02:56 AM
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 152
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Multithreading and locking?

One example worth looking at is the PIDController. It spawns a task which updates every 50ms from the PIDInput and writes its results to PIDWrite. That will serve as a good example. But if there's a lack of clarity as to what you're really trying to do, here's "it" in a nutshell. Since you have two tasks running at the same time, one must be careful to not wind up modifying something while it is being read by the other task. The lock basically says that the other task cannot get their lock until you unlock on the other one. One must also be careful to program in a manner where you always give up a lock that you've taken - or else the other thread will be forever waiting to gain the lock which you never give up.... and similarly, if you take a lock, you have to be careful to make sure you don't accidentally call a function which tries to take the lock a 2nd time which would result in the same deadlock situation.

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #3   Spotlight this post!  
Unread 04-22-2012, 12:03 PM
rbmj rbmj is offline
Registered User
FRC #0612 (Chantilly Robotics)
Team Role: Alumni
 
Join Date: Apr 2011
Rookie Year: 2011
Location: DC Area/Fairfax County
Posts: 192
rbmj is a jewel in the roughrbmj is a jewel in the roughrbmj is a jewel in the rough
Re: Multithreading and locking?

Quote:
Originally Posted by Ether View Post
Zera's Law: Once you realize that something bad can happen, it will.


I can attest to that. As soon as I took a second look at our code I realized that we'd had static initialization order issues, and sure enough, a few days later it segfaulted...

The AxisCamera code also has some locking that you can look at. We also wrapped it a little in our code: https://github.com/rbmj/612-code/blo...ion_thread.cpp
Reply With Quote
  #4   Spotlight this post!  
Unread 09-13-2012, 07:32 PM
jacob9706 jacob9706 is offline
Registered User
AKA: Jacob Ebey
FRC #3574 (High Tekerz)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Seattle
Posts: 101
jacob9706 is on a distinguished road
Re: Multithreading and locking?

Quote:
Originally Posted by rbmj View Post
I can attest to that. As soon as I took a second look at our code I realized that we'd had static initialization order issues, and sure enough, a few days later it segfaulted...

The AxisCamera code also has some locking that you can look at. We also wrapped it a little in our code: https://github.com/rbmj/612-code/blo...ion_thread.cpp
I was looking through your code and do you realize you can use namespaces?

so for example right after your includes you would put something like this...

using namespace cv;
using namespace std;


Now that you have that instead of doing something like

std::cout << cv:oint(10,10) << std::endl;

You can now do this

cout << Point(10,10) << endl;

Just something I thought I would share with everyone.
__________________
/*
* Team 3574 Alumni
*
* 2011 - Highest Seeded Rookie
* 2011 - Rookie All-Star
* 2012 - Engineering Inspiration
* 2012 - Olympic Deans List Winner
* 2013 - Engineering Inspiration
* 2013 - Judges Award (For unique circular robot and the way the team works together.)
*/
Reply With Quote
  #5   Spotlight this post!  
Unread 08-03-2015, 12:10 PM
knuckleduster knuckleduster is offline
Registered User
AKA: Jack Manning
FRC #0058 (The Riot Crew)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: South Portland
Posts: 12
knuckleduster is an unknown quantity at this point
Re: Multithreading and locking?

Quote:
Originally Posted by jacob9706 View Post
I was looking through your code and do you realize you can use namespaces?

so for example right after your includes you would put something like this...

using namespace cv;
using namespace std;

Just something I thought I would share with everyone.
Actually, it isn't really considered good practice to use namespaces, when you start using multiple libraries with similarly named functions, it can get hectic, and its just better to get into the habit of not using them if possible.
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 10:49 AM.

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