Can I always assume that if...
int main()
{
...
foo1();
foo2();
foo3();
...
return 0;
}
that foo1() will always precede foo2() and foo2() will always precede foo3() in program completion (referring to highest abstraction of completion)?
In my actual program, whether foo2() and foo3() happen depend on whether foo1 is a very "long" function, meaning if there is a giant for loop in foo1(), then by the time I finish and get to the end of the program, foo2(), and foo3() don't happen. In my program foo1()-foo3() access the same map. f001() initializes all usable elements in the map and foo2(),foo3() then replace initializations with aliasing data read from files. Any reason why this is happening?
Here are the 2 functions, the rest of the program is sortof large and off topic:
void loadDEADBEEF()
{
for (long long i=0; i<=268435888; i+=4)//268435888
{
MainMemory[i] = 3735928559;
HEXMainMemory[i] = "DEADBEEF";
}
}
void LoadMemory(string str)//load hex dump into memory
{
filecounter++;
vector<int> V;//temperary vector
vector<string> tempV;//temperary vector
ifstream inClientFile( str.c_str(),ios::in ); //stream object
vector<string> words;
string word;
int offset=0;
if ( !inClientFile ) cerr << "File couldn't be opened" << endl;//test if instruction file can be opened
//fill string vector with all file values and determines length of program
while (inClientFile >> word)words.push_back(word);//capture raw code from file
const int wordCount=words.size();//determine most efficient sizing for vectors
tempV.reserve(wordCount);//size vector
for(int i=0; i<wordCount; i++)
{
if (i==0 && words[i].length()==10) tempV.push_back(words[i]);//include first word to obtain data offset (memory insertion point)
if (words[i].length()==8
&& words[i].find(".")==string::npos )
tempV.push_back(words[i]);//cut out undesired strings from vector
}
for( int y=2; y<10; y++) offset+=hexCharValue(tempV[0][y])<<(4*(9-y));//convert offset from hex to decimal
tempV.erase(tempV.begin());//delete offset from vector
V.resize(tempV.size());//resize vector
for( int j=0; j<tempV.size(); j++ )//convert string hex to numerical decimal
{
for( int y=0; y<8; y++) V[j]+=hexCharValue(tempV[j][y])<<(4*(7-y));//4194608+4*
if (load_memory)
{
MainMemory.insert(mapType::value_type(4*j+offset,V[j]));//insert (location in memory,data)
HEXMainMemory.insert(pair<int, string>(4*j+offset,tempV[j]));
}
}
if( filecounter == 1 ) PC_start = offset-4;
}
So, the first function is "foo1()" and the second is "foo2()". Here is main:
#include
...
typedef map<int, int> mapType;//format of map: ( address, data )
typedef map<int, string> mapType2;//format of map: ( address, data )
mapType MainMemory;
mapType2 HEXMainMemory;
...
int main(int argc, char **argv)
{
...
loadDEADBEEF();
LoadMemory("hello_1.txt");//reginfo
...
return 0;
}
foo1()doing anything with multiple threads? If there is no threading anywhere,foo2()andfoo3()will run sequentially afterfoo1()as completed. If there are threads, all bets are off and the answer is a bit more complicated.