Is there any ways to make synchronization between 2 functions in C/C++? I leant from ADA language, there is a keyword `RENDEZVOUS' doing that.
You need to use the threading capabilities of your chosen os to simulate this functionality.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
Something like...Can you elaborate what ``RENDEZVOUS'' does? (I tend to believe there aren't many ADA programmers reading the board)
main() calls 2 functions simultaneously and both work independently when some value in those functions match together, both functions return to main().
for realistic...
In case aircraft will get landed...
A function detects altitude. The other function detects speed.
For sure both work simultaneously and independently. But before the aircraft gets landed, its altitude and speed must match together. If not, warning alarm bells.
(I have an example of ADA using `rendezvous' But I don't code it here, I'm afraid that no one will read it and it might violate board regulations)
Anyway I shall try POSIX pthread
Thanks,
If what I'm getting is that you want them to run many functions at the same time and then continue when all of them are finished then this should work fine:
If what you want is to lock a resource so that only one thread can use it at one time, it gets a little trickier. Use a little templated class to hold a boolean if its being used or not.Code:void Function1(int &done) { // stuff here... done++; } void Function2(int &done) { // stuff here... done++; } int main() { int done=0; // you can have them both run in seperate threads // or have just the first one in a new thread // ...implementation specific... Function1(done); Function2(done); // wait until they are both done while (done!=2); // continue here... return 0; }
Last edited by Speedy5; 03-18-2003 at 02:51 PM.