473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

break , continue, how to understand

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
3 2040
>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
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
Hi Malte,

I learnt a nice lesson from your post:

NEVER TRUST MICRO$OFT !!!

;-)

Thx

Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2598
by: Glen Wheeler | last post by:
Hello All. I've been coding in python for a reasonable amount of time now (coding in total for approx. 20 years) and am writing a performance intensive program in python. The problem I'm having...
5
2526
by: Ann | last post by:
I have trouble sometimes figuring out where break and continue go to. Is there some easy way to figure it out, or a tool? TIA Ann
3
20998
by: Matt | last post by:
Hi I am trying to figure out how to exit a cursor loop if a specified condition occurs. I have a select count(*) on a table like this select lagplats, count(*) from arsi where artnr =...
5
33686
by: viza | last post by:
Hi! Suppose I have int i,j,k; for(i=0;i<I;++i){ /* loop 1 */ for(j=0;j<J;++j){ /* loop 2 */ for(k=0;k<K;++k){ /* loop 3 */ if(test){
26
2494
by: Chris Potter | last post by:
Hello everyone. I am taking my first course in C and in one of my assignments i need to print out an array that could have anywhere from 0 to 100 positive integers in it (a negative integer is...
25
3883
by: chunhui_true | last post by:
In <<expert c>>I know the break in if wich is scoped in switch is break the switch,like: switch c case 1: if(b){ break; } ...... But like this: while(a){
5
40195
by: tony collier | last post by:
To break out of a loop i have seen some people use RETURN instead of BREAK I have only seen RETURN used in functions. Does anyone know why RETURN is used instead of BREAK to kill loops?
14
6235
by: serrand | last post by:
Could someone tell me a beautiful way to exit from a switch and a loop in one statement ... without using a goto... and if possible without using an auxiliary variable as i did... int res;...
26
10180
by: Alexander Korsunsky | last post by:
Hi! I have some code that looks similar to this: -------------------------------------------- char array = "abcdefghij"; for (int i = 0; i < 10; i++) {
0
7254
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1585
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.