By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,851 Members | 2,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,851 IT Pros & Developers. It's quick & easy.

break , continue, how to understand

P: n/a
const DInst *stopAtDst = 0;

while (dinst->hasPending()) {

if (stopAtDst == dinst->getFirstPending())
break; ///////break? break? break? is this break outof the whole
while loop and never in the loop again???????????????????????

DInst *dstReady = dinst->getNextPending();

if (!dstReady->isIssued()) {

// Accross processor dependence
if (dstReady->hasDepsAtRetire())
dstReady->clearDepsAtRetire();

continue; //////continue?? continue?? continu?? is this continue
means finish this iteration of the loop and continue working on the next
iteration of the loop if any
}
if (dstReady->isExecuted()) {
if (!dstReady->hasDeps())
dstReady->scrap(); //dInstPool.in(this)
continue;
}

if (dstReady->hasDepsAtRetire() && dinst->getInst()->isStore()) {
dosomething;
}
}
Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
>const DInst *stopAtDst = 0;

while (dinst->hasPending()) {

if (stopAtDst == dinst->getFirstPending())
break; ///////break? break? break? is this break outof the
whole
while loop and never in the loop again???????????????????????

Yes you are right, here! :-)

DInst *dstReady = dinst->getNextPending();

if (!dstReady->isIssued()) {

// Accross processor dependence
if (dstReady->hasDepsAtRetire())
dstReady->clearDepsAtRetire();

continue; //////continue?? continue?? continu?? is this
continue
means finish this iteration of the loop and continue working on the
next
iteration of the loop if any

No, you are wrong here!!
This 'continue;' will NOT finish this current iteration. Instead, this
continue statement will force the control to jump directly to the
'while (dinst->hasPending())' again (i.e. to the next iteration,
WITHOUT finishing the current iteration).
Now, whether this iteration (i.e. the next iteration) is executed or
not depends upon wheteher 'dinst->hasPending()' is true or false.

Maybe you'll find these links helpful:
http://msdn.microsoft.com/library/en...asp?frame=true
http://msdn.microsoft.com/library/en...asp?frame=true

Jul 23 '05 #2

P: n/a
ra*********@gmail.com schrieb:
Maybe you'll find these links helpful:
http://msdn.microsoft.com/library/en...asp?frame=true
http://msdn.microsoft.com/library/en...asp?frame=true


What they say about break and continue seems right. OTOH I would
definately refrain from recommending those links because of these:
* The heading "C/C++ Language Reference" - there is no C/C++ language.
There is C and there is C++.
* The examples are written in C (#include <stdio.h>, printf(), NULL
instead of 0)
* The example for continue uses a platform-specific API (_getche())
* The examples are neither valid in C nor in C++ (void main())

Cheers,
Malte
Jul 23 '05 #3

P: n/a
Hi Malte,

I learnt a nice lesson from your post:

NEVER TRUST MICRO$OFT !!!

;-)

Thx

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.