468,512 Members | 1,408 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

Enable simultaneous looping

Ali Rizwan
927 512MB
How can i play to loops simultaniously.
For example

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<=100;i++)
  2. cout<<"My name is ali";
and

Expand|Select|Wrap|Line Numbers
  1. for(int j=0;j<=100;j++)
  2. cout<<"Your name is ";
now both loops have to start at same time and play simeltaniuosly.

I m using Borland C
Version is 3

Thanx
>> ALI <<
Jan 14 '08 #1
10 3147
gpraghuram
1,275 Expert 1GB
How can i play to loops simultaniously.
For example

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<=100;i++)
  2. cout<<"My name is ali";
and

Expand|Select|Wrap|Line Numbers
  1. for(int j=0;j<=100;j++)
  2. cout<<"Your name is ";
now both loops have to start at same time and play simeltaniuosly.

I m using Borland C
Version is 3

Thanx
>> ALI <<
If You want this to happen parallel then you should go for multi-threading.
You can use posix multi threading and i think POSIX is supported by Borland

Raghuram
Jan 14 '08 #2
sicarie
4,677 Expert Mod 4TB
And just out of curiosity (as the bounds are the same on each), is

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<=100;i++) {
  2.    cout<<"My name is ali";
  3.    cout<<"Your name is ";
  4. }
not an option?

PS - Please check your Private Messages by clicking on the PMs link in the top right corner of the page. Thanks.
Jan 14 '08 #3
Ali Rizwan
927 512MB
And just out of curiosity (as the bounds are the same on each), is

Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<=100;i++) {
  2.    cout<<"My name is ali";
  3.    cout<<"Your name is ";
  4. }
not an option?

PS - Please check your Private Messages by clicking on the PMs link in the top right corner of the page. Thanks.
I m sorry but the code is not the same as there. This is an example.
Actually i have two animations and i want to run them simultaneously.
If i do as you are saying that combine them both then there is a big delay between them, that is why i want to run two loops.

Thanx

>> ALI <<
Jan 14 '08 #4
sicarie
4,677 Expert Mod 4TB
I m sorry but the code is not the same as there. This is an example.
Actually i have two animations and i want to run them simultaneously.
If i do as you are saying that combine them both then there is a big delay between them, that is why i want to run two loops.

Thanx

>> ALI <<
Ah, yes, well that is quite different, I would recommend looking into Raghuram's suggestion.
Jan 14 '08 #5
By using OpenMP API which is inbuilt in Visual Studio 2005 beta version


#include<omp.h>

#pragma omp sections num_Threads(n)
{
#pragma omp section
{
for(int i=0;i<=100;i++)
cout<<"My name is ali";
}
#pragma omp section
{
for(int j=0;j<=100;j++)
cout<<"Your name is ";
}
}


Asadullah ansari
Jan 15 '08 #6
Ali Rizwan
927 512MB
If You want this to happen parallel then you should go for multi-threading.
You can use posix multi threading and i think POSIX is supported by Borland

Raghuram
Can you tell me how can i do this?
I am novice in c++ and don't know too much

Thanx
>> ALI <<
Jan 15 '08 #7
Ali Rizwan
927 512MB
By using OpenMP API which is inbuilt in Visual Studio 2005 beta version

Asadullah ansari
I have mentioned the C++ compiler and version plz tell me associated with that.

thanx
>> ALI <<
Jan 15 '08 #8
oler1s
671 Expert 512MB
So, Ali Rizwan, Iím going to call you out as a help vampire as well. We told you that if you wanted to run two instructions simultaneously, you need to implement multithreading. Using various APIs like OpenMP can help.

We answered your question. So you come back here and say, how, how? Well, google it. The information is not a one line answer. Itís a serious topic, and we pointed you in the right direction. If you refuse to spend any effort on learning, then sadly, you arenít the enlightened developer your avatar title says it is.
Jan 15 '08 #9
sicarie
4,677 Expert Mod 4TB
I have mentioned the C++ compiler and version plz tell me associated with that.

thanx
>> ALI <<
Ali-

Didn't we just talk about this? Pro-active means you actually try it yourself. Please take oler1s' post to heart, I would hate to have to take action against any member, but I PM'd you yesterday about trying to do things before you posted on them...
Jan 15 '08 #10
gpraghuram
1,275 Expert 1GB
Can you tell me how can i do this?
I am novice in c++ and don't know too much

Thanx
>> ALI <<

Look at this book which says about multi-threading in Linux.(Chapter 4)
Take a look and post me if you need mor info about this

Raghuram
Jan 16 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

19 posts views Thread by Claudio Grondi | last post: by
6 posts views Thread by Jimnbigd | last post: by
1 post views Thread by Ed Chiu | last post: by
3 posts views Thread by vovan | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.