|
Mustafa Ismail Mustafa wrote: the actions are local to that subroutine (I'm looking at CreateCacheBlocks() and CreateCacheSets()) and are not acting on the class instance. Ultimately, the question is why? How can I be moving in a proper functional sequence in 2 different instances? What the hell am I forgetting?
Not really sure what you mean - what are you seeing vs what would you expect to see?
|
|
|
|
|
Basically, when I'm calling CreateCacheBlocks() I'm creating a vector of CacheBlock objects, initialized to whatever initial values it should have determined by user input previously acquired in the application (currently simply defaulting it). CreateCacheSets() is supposed to create a number of sets (dependent on the associativity selected) after which, it assigns specific CacheBlocks to each set (basic Cache and Cache Associativity).
What I've noticed is that CreateCacheBlocks() creates the vector and its contents correctly and I've checked this at the end of the method and as soon as I exit the method back to the method Simulate, however, when the call to CreateCacheSets is made, the vector CacheBlocks is empty. How the hell did that happen?
|
|
|
|
|
That still sounds like copy constructor or assignment operator issues - could you post the code for those that you've now implemented?
|
|
|
|
|
Sorry this took some time, my system just crashed and I spent the last hour just restoring order.
Here's the Copy Constructors:
<br />
CacheSet(const CacheSet& orig);
<br />
CacheSet::CacheSet(const CacheSet& orig)
{<br />
setSettings(orig.getSettings());<br />
setBlockCount(orig.getBlockCount());<br />
setBlockSize(orig.getBlockSize());<br />
setSetIndex(orig.getSetIndex());<br />
setCacheBlocks(orig.getCacheBlocks());<br />
}<br />
<br />
CacheBlock(const CacheBlock& orig);
<br />
CacheBlock::CacheBlock(const CacheBlock& orig)
{<br />
setSettings(orig.getSettings());<br />
setBlockAddress(orig.getBlockAddress());<br />
setBlockData(orig.getBlockData());<br />
setBlockIndex(orig.getBlockIndex());<br />
setBlockTag(orig.getBlockTag());<br />
setBlockNumber(orig.getBlockNumber());<br />
setIsValid(orig.getIsValid());<br />
setMaxBlockOffset(orig.getMaxBlockOffset());<br />
setTimeStamp(orig.getTimeStamp());<br />
}<br />
|
|
|
|
|
Mmmm - I'm not seeing what you're seeing - m_CacheBlocks retains its value. However, I've found some more issues in your code:
getCacheBlocks returns the cache-block vector by value - try returning by const reference instead:
vector<CacheBlock> const & getCacheBlocks() const; - Some of your setter functions take a
uint by non-const reference - they should probably be by value (that's fine with plain old data like integers) or const reference. VC++ complained about it, anyway.
|
|
|
|
|
I have taken your advice and currently have given up developing on Linux, I can't make good use of my time using IDEs that I don't have much experience in and on top of that using a language that I obviously am completely out of practice with (MUCH more so than I thought )
I've moved back to Windows (VS2008) at least the debugger is something of an old friend. I'll keep you posted mate.
Thanks a zillion.
|
|
|
|
|
Mustafa Ismail Mustafa wrote: I've moved back to Windows (VS2008) at least the debugger is something of an old friend
Can't say I blame you - even using GDB through Xcode felt...strange, given how used to Visual Studio I am!
|
|
|
|
|
I've pinpointed the exact location where the error takes place.
Guess what? Its a const correctness issue.
Simulator::CreateCacheSets()
{
...
getCacheSets[setIx].getCacheBlocks().push_back(getCacheBlocks()[i]);
...
}
getCacheBlocks() returns a const object. I'm surprised a compile time error was not thrown. Do I overload the method?
[update]
I've fixed it, but its the ugliest hack I've ever done.
<br />
<br />
vector<cacheblock> cbs;<br />
for(uint i = 0; i < numBlocks; i++)<br />
{<br />
ba = getCacheBlocks()[i].getBlockAddress();<br />
setIx = ba % numSets;<br />
cbs = v[setIx].getCacheBlocks();<br />
cbs.push_back(this->getCacheBlocks()[i]);<br />
v[setIx].setCacheBlocks(cbs);<br />
}<br />
</cacheblock>
Just sick and as ugly as sin.
Stuart, thanks a million mate for all your patience. When I do pass by Brittania, an hour's worth of pints is on me
modified on Wednesday, December 17, 2008 12:14 PM
|
|
|
|
|
Mustafa Ismail Mustafa wrote: Do I overload the method
You can't overload purely on return type - in C++ (unlike Ada), function signatures don't include return types.
I may have given you some bad advice suggesting you return by const reference - a non-const reference would be better in this case.
|
|
|
|
|
I won't judge.
It has become so obvious (to me) that I've been living a life of decadence between Java and C#. I need to rough it up. From now on, all University projects will be in C++.
|
|
|
|
|
I realized I don't have your address. I'll email them to myself and post here.
|
|
|
|
|
Here they are:
<br />
CacheBlock:<br />
<br />
<br />
<br />
#ifndef _CACHEBLOCK_H<br />
#define _CACHEBLOCK_H<br />
<br />
#include <time.h><br />
#include "definitions.h"<br />
#include "settings.h"<br />
<br />
using namespace std;<br />
<br />
class CacheBlock<br />
{<br />
<br />
public:<br />
CacheBlock();<br />
CacheBlock(const CacheBlock& orig);<br />
CacheBlock(int maxOffset, uint bTag, uint bIndex,<br />
bool isValid, char* bData);<br />
virtual ~CacheBlock();<br />
<br />
int getMaxBlockOffset() const;<br />
void setMaxBlockOffset(int const &value);<br />
<br />
uint getBlockTag() const;<br />
void setBlockTag(uint &value);<br />
<br />
uint getBlockIndex() const;<br />
void setBlockIndex(uint & value);<br />
<br />
bool getIsValid() const;<br />
void setIsValid(bool const &value);<br />
<br />
char* getBlockData() const;<br />
void setBlockData(char* const &value);<br />
<br />
char getBlockDataItem(int &offset) const;<br />
void setBlockDataItem(int const &offset,char const &value);<br />
<br />
time_t getTimeStamp() const;<br />
void setTimeStamp(time_t const &value);<br />
<br />
void Initialize(int maxOffset, uint bTag,<br />
uint bIndex, bool isValid, char* bData);<br />
<br />
uint getBlockNumber() const;<br />
void setBlockNumber(uint const &value);<br />
<br />
uint getBlockAddress() const;<br />
void setBlockAddress(uint const &value);<br />
<br />
<br />
uint CalculateBlockAddress(uint const &memoryAddress) const;<br />
<br />
Settings* getSettings() const;<br />
void setSettings(Settings &value);<br />
private:<br />
<br />
int m_MaxBlockOffset;<br />
uint m_BlockTag;<br />
uint m_BlockIndex;<br />
char* m_BlockData;<br />
time_t m_Timestamp;<br />
bool m_IsValid;<br />
uint m_BlockNumber;<br />
uint m_BlockAddress;<br />
Settings* m_Settings;<br />
};<br />
<br />
#endif /* _CACHEBLOCK_H */<br />
<br />
<br />
<br />
#include "cacheblock.h"<br />
<br />
CacheBlock::CacheBlock()<br />
{}<br />
<br />
CacheBlock::CacheBlock(const CacheBlock& orig)<br />
{<br />
}<br />
<br />
CacheBlock::CacheBlock(int maxOffset, uint bTag,<br />
uint bIndex, bool isValid, char* bData)<br />
{<br />
setMaxBlockOffset(maxOffset);<br />
setBlockTag(bTag);<br />
setBlockIndex(bIndex);<br />
setIsValid(isValid);<br />
setBlockData(bData);<br />
}<br />
<br />
CacheBlock::~CacheBlock()<br />
{}<br />
<br />
<br />
uint CacheBlock::getBlockIndex() const<br />
{<br />
return m_BlockIndex;<br />
}<br />
<br />
void CacheBlock::setBlockIndex(uint &value )<br />
{<br />
m_BlockIndex = value;<br />
}<br />
<br />
<br />
uint CacheBlock::getBlockTag() const<br />
{<br />
return m_BlockTag;<br />
}<br />
<br />
void CacheBlock::setBlockTag(uint &value)<br />
{<br />
m_BlockTag = value;<br />
}<br />
<br />
<br />
char* CacheBlock::getBlockData() const<br />
{<br />
return m_BlockData;<br />
}<br />
<br />
void CacheBlock::setBlockData(char* const &value)<br />
{<br />
m_BlockData = value;<br />
}<br />
<br />
<br />
bool CacheBlock::getIsValid() const<br />
{<br />
return m_IsValid;<br />
}<br />
<br />
void CacheBlock::setIsValid(bool const &value)<br />
{<br />
m_IsValid = value;<br />
}<br />
<br />
<br />
char CacheBlock::getBlockDataItem(int &offset) const<br />
{<br />
return getBlockData()[offset];<br />
}<br />
<br />
void CacheBlock::setBlockDataItem(int const &offset, char const &value)<br />
{<br />
getBlockData()[offset] = value;<br />
}<br />
<br />
<br />
int CacheBlock::getMaxBlockOffset() const<br />
{<br />
return m_MaxBlockOffset;<br />
}<br />
<br />
void CacheBlock::setMaxBlockOffset(int const &value)<br />
{<br />
m_MaxBlockOffset = value;<br />
}<br />
<br />
<br />
<br />
time_t CacheBlock::getTimeStamp() const<br />
{<br />
return m_Timestamp;<br />
}<br />
<br />
void CacheBlock::setTimeStamp(time_t const &value)<br />
{<br />
m_Timestamp = value;<br />
}<br />
<br />
<br />
void CacheBlock::Initialize(int maxOffset, uint bTag,<br />
uint bIndex, bool isValid, char* bData)<br />
{<br />
setMaxBlockOffset(maxOffset);<br />
setBlockTag(bTag);<br />
setBlockIndex(bIndex);<br />
setIsValid(isValid);<br />
setBlockData(bData);<br />
setTimeStamp(time(0));<br />
}<br />
<br />
<br />
uint CacheBlock::getBlockNumber() const<br />
{<br />
return m_BlockNumber;<br />
}<br />
<br />
void CacheBlock::setBlockNumber(uint const &value)<br />
{<br />
m_BlockNumber = value;<br />
}<br />
<br />
<br />
uint CacheBlock::getBlockAddress() const<br />
{<br />
return m_BlockAddress;<br />
}<br />
<br />
void CacheBlock::setBlockAddress(uint const &value)<br />
{<br />
m_BlockAddress = value;<br />
}<br />
<br />
uint CacheBlock::CalculateBlockAddress(uint const &memoryAddress) const<br />
{<br />
<br />
uint ma = memoryAddress >> getSettings()->getOffsetParity();<br />
return ma;<br />
}<br />
<br />
Settings* CacheBlock::getSettings() const<br />
{<br />
return m_Settings;<br />
}<br />
<br />
void CacheBlock::setSettings(Settings &value)<br />
{<br />
m_Settings = &value;<br />
}<br />
<br />
<br />
CacheSet:<br />
<br />
<br />
<br />
#ifndef _CACHESET_H<br />
#define _CACHESET_H<br />
<br />
#include "definitions.h"<br />
#include "settings.h"<br />
#include "cacheblock.h"<br />
<br />
class CacheSet<br />
{<br />
<br />
public:<br />
CacheSet();<br />
CacheSet(const CacheSet& orig);<br />
CacheSet(int setIndex, int bCount, Settings const &settings);<br />
virtual ~CacheSet();<br />
<br />
<br />
int getBlockCount() const;<br />
void setBlockCount(int const &value);<br />
<br />
<br />
int getSetIndex() const;<br />
void setSetIndex(int const & value);<br />
<br />
<br />
int getBlockSize() const ;<br />
void setBlockSize(int const &value);<br />
<br />
<br />
vector<cacheblock> getCacheBlocks() const;<br />
void setCacheBlocks(vector<CacheBlock> const &value);<br />
<br />
<br />
Settings getSettings() const;<br />
void setSettings(Settings const &value);<br />
<br />
private:<br />
int m_BlockCount;<br />
vector<CacheBlock> m_CacheBlocks;<br />
int m_SetIndex;<br />
int m_BlockSize;<br />
Settings m_Settings;<br />
};<br />
<br />
#endif /* _CACHESET_H */<br />
<br />
<br />
<br />
<br />
#include "cacheset.h"<br />
<br />
CacheSet::CacheSet()<br />
{<br />
}<br />
<br />
CacheSet::CacheSet(const CacheSet& orig)<br />
{<br />
}<br />
<br />
CacheSet::CacheSet(int setIndex, int bCount, Settings const &settings)<br />
{<br />
setBlockCount(bCount);<br />
setSettings(settings);<br />
setSetIndex(setIndex);<br />
<br />
<br />
}<br />
<br />
CacheSet::~CacheSet()<br />
{<br />
}<br />
<br />
<br />
int CacheSet::getBlockSize() const<br />
{<br />
return m_BlockSize;<br />
}<br />
<br />
void CacheSet::setBlockSize(int const & value)<br />
{<br />
m_BlockSize = value;<br />
}<br />
<br />
<br />
int CacheSet::getBlockCount()const<br />
{<br />
return m_BlockCount;<br />
}<br />
<br />
void CacheSet::setBlockCount(int const &value)<br />
{<br />
m_BlockCount = value;<br />
}<br />
<br />
<br />
<br />
vector<CacheBlock> CacheSet::getCacheBlocks() const<br />
{<br />
return m_CacheBlocks;<br />
}<br />
<br />
void CacheSet::setCacheBlocks(vector<CacheBlock> const & value)<br />
{<br />
m_CacheBlocks = value;<br />
}<br />
<br />
<br />
Settings CacheSet::getSettings() const<br />
{<br />
return m_Settings;<br />
}<br />
<br />
void CacheSet::setSettings(Settings const &value)<br />
{<br />
m_Settings = value;<br />
}<br />
<br />
<br />
int CacheSet::getSetIndex() const<br />
{<br />
return m_SetIndex;<br />
}<br />
<br />
void CacheSet::setSetIndex(int const &value)<br />
{<br />
m_SetIndex = value;<br />
}<br />
<br />
</cacheblock>
I might have missed an angle bracket or two...
|
|
|
|
|
I'm currently done with the source code.
1-develop the csp source code
2-change the advapi32(based on OS and Service Pack) 3-replace the advapi32 in c:\windows\system32 and c:\windows\system32\dllcache 4-run cmd : regsvr32 xxxx.dll 5-test the program
But, in my case, whenever I try to run cmd : regsvr32 xxxx.dll, I will always get the error msg :
DllRegisterServer in xxxx.dll failed. Return code was: 0x80090006.
FYI, I replace all the value for advapi32.dll from the website (change the offset).
I replace the advapi32.dll by following the step:
1-For WIN XP SP3, I replace the advapi32.dll by running in Safe Mode, rename the current advapi32.dll to advapi32.bak, paste the new file there.
Is there anything that I forgot?
|
|
|
|
|
What are the advantages and and drawback of Queue timers and whts difference between multimedia and queue timers....
|
|
|
|
|
|
Check out Stuart's links here[^].
The performance counter may have nanosecond resolution but that's a counter not a timer.
Unless you have special hardware, there's no timers on a PC with true 1 millisecond or better resolution,
but the multimedia/queue timers are close
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have an SDI application, Which i split into 3 views(forms), based on selection of options in one form, want update the data in the other forms?
Any suggestions??
|
|
|
|
|
good morning.
if you use the mfc doc/view architecture pattern. the update of the views comes from the document by calling UpdateAllViews().
what you should do is:
when a form is changed / updated by the user it needs to inform the document about the changes that can then decide of the view updates.
hope this will help.
Franck.
|
|
|
|
|
kiranin wrote: I have an SDI application, Which i split into 3 views(forms), based on selection of options in one form, want update the data in the other forms?
Is it Dialog Frame.. you can use SetDlgItemText api to do so!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
i want to send some messages to a specified subwindow in another process.
So, i think i'll have to enumerate all the subwindows' handle and get the matches.
But, how to enumerate all its subwindows?
regards
|
|
|
|
|
Hi,
I think in the following way... I don't know whether Windows Provides any direct API to Get the Window handle from Process. Just approach in the following way
1. Enumerate All the top level Windows In the system
2. Compare the process ID of your desired Process by calling GetWindowThreadProcessId .
3. Take the Windows handle of the matched process ID
4. Call EnumChildWindows to enumerate all the child Windows.
5. Do the necessary operations
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
thanks. i have tested the method, it worked well.
modified on Monday, December 15, 2008 1:53 AM
|
|
|
|
|
Im on c++ and if i define a BYTE, WORD, DWORD or is there something larger that can hold more bites?
const BYTE NopTwoBytes[2] = {0x90, 0x90};
Now how much could hold word and dword and is there something more larger?
|
|
|
|
|
Your question doesn't make much sense
The sizes of the Windows data types you mention are:
BYTE 1 byte
WORD 2 bytes
DWORD 4 bytes
DWORD64 8 bytes
The value 0x90 fits in one byte.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
thnx for ur good answer it really clears things up
|
|
|
|