|
Maybe you didnt get me right, but my aim was to tell you that the InterlockedIncrement in kernel32.dll if you decompile it, or follow it through a debugger, will have the assembly in my previous post. Which is "the same" as the intrinsic version.
Whether or not this is safe, or stable has nothing to do with it. If intel and microsoft decided to change the way the LOCK on the memory system bus happen your application would suffer. But that is highly unprobable.
What i would like to understand, is, what gain you get if you use the intrinsic form?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
My question was just this:
the intrinsic form is documented for VC7, but not for VC6, however, it seems to work on VC6. Are there any known reasons why it wasn't documented? Or any known problems using it with VC6? (might be the optimizer barfing in some cases, or whatever)
Papa wrote:
What i would like to understand, is, what gain you get if you use the intrinsic form?
possible optimizations, since the function can be inlined:
- no function call, stack frame etc.
- this pointer likely in register
- unused return value optimization (the inc eax)
- reuse of a register known to hold the value 1
- better pairing ofthe staements (esp. the lock xadd)
Assuming the this pointer is already in eax , and we are not interested in the return value, the emitted code for InterlockedIncrement(&m_count) falls down to two instructions:
<br />
mov ecx, 1<br />
lock xadd [eax + offset m_count], ecx<br />
Now admittedly the "lock" is pretty much a showstopper and will amount the biggest performance hit. I guess I just pefer a few inlined instructions over a call into kernel32.dll
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
Is there a way that I can change the actual bytes in the file without reading them into memory? If I have a CFile object, I would like to be able to change every other byte, which would not be as slow as reading all the bytes into memory, then changing them then writing them back, which is VERY slow. Any help would be appreciated.
[insert witty comment here]
bdiamond
|
|
|
|
|
Check Seek and Write
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
What you describe/desire would be painfully slow, as you are operating on a byte-by-byte basis. Read the entire file into a buffer using a single call to Read() . Change the bytes are necessary. Write the entire file from the buffer using a single call to Write() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
The way you just described is what I tried at first (although with a CFile object, which may or may not have made it slower). The file was about 300 MB and it was taking so long that I had to terminate the process. I found and modified an algorithm that (after I modified it) reads chunks of no more than 1024 bytes at a time. In a FOR loop for every KB, I increment the counter by two for each iteration and switch the array[i] and array[i + 1] elements and write that to the second file. I do this until all the way through the file. I tested and timed it on a file of over 400 MB and it was done in 1 minute 25 seconds! So that turned out to be what I wanted. You just take the desired file and drop it on the exe, and it goes to work. The only problem I'm still having is that the console window shows up during that whole minute if it's a big file, and I would like to find a way to suppress that. I thank you for answering my question and feel bad if I wasted your time. Maybe I'll start posting replies to my own message with something like 'SOLVED' in the subject so people will know.
[insert witty comment here]
bdiamond
|
|
|
|
|
Since you are reading the file in chunks, you'd be well served by using CMemFile . It'll take that 85 seconds down a few notches.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I am populating my list ctrl using the InsertItem method and it works fine because I see everything I want there. The only problem is that the scroll bars will not show up.
the only way to make them appear is to select an item and scroll down the list with the arrow keys. As soon as I scroll down to the border, the scroll bars appear.
Any way to force them to be them from the beginning ?
When I populated the list ctrl using SetItemText, it was working fine.
thanks,
Shay
|
|
|
|
|
Shay Harel wrote:
...the scroll bars will not show up.
Which one, the horizontal or the vertical?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Vertical.
Here is the code I use to inser the items.
<br />
LV_ITEM lvi;<br />
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM; <br />
lvi.iItem = index; <br />
lvi.iSubItem = 0; <br />
lvi.iImage = image;<br />
lvi.pszText = LPSTR_TEXTCALLBACK; <br />
lvi.lParam = (LPARAM) pItem;
<br />
if (m_ctl_files_list.InsertItem (&lvi) == -1)<br />
return 0;
Any way to force the scroll bar to show up ?
|
|
|
|
|
I've not ever seen this type of behavior before. By default, a list control's scroll bar will show up as soon as an item is added that is at or near the bottom of the control. Using Spy++, can you tell me what styles that control has?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Can anybody tell me how to determine which colour scheme is currently being used (blue, olive or silver)?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
|
Dear:
I having problem with this code :
[Code]
CDatabase dbConnection;
dbConnection.Open("ODBC;DSN=TestDB;uid=sa;pwd=");
CRecordset dbRecord(&dbConnection);
BOOL b = dbRecord.CanUpdate();//here Debug assertion failure rasied ,WHY?
Regards
|
|
|
|
|
Check CRecordset::Open
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I am trying to create an istance of the windows media player control but it returns an error... here is my code:
<br />
HRESULT hret;<br />
IUnknown *pUnknown; <br />
MediaPlayer::IMediaPlayerPtr pMediaPlayer = NULL;<br />
IConnectionPoint *pConnectionPoint;<br />
IConnectionPointContainer *pConnectionPointContainer;<br />
IOleInPlaceObject *pInPlaceObject;<br />
IOleObject *pObject;<br />
DWORD dwAdviseCookie;<br />
<br />
<br />
hret = CoCreateInstance(__uuidof(MediaPlayer::IMediaPlayerPtr), NULL, CLSCTX_ALL, pMediaPlayer.GetIID(), (void**)(&pMediaPlayer));<br />
Thank you very much for your answers in advance...
Well... I am a beginner ...
|
|
|
|
|
What error are you getting?
Did you call CoInitialize() before the CoCreateInstance?
Michael
CP Blog [^]
|
|
|
|
|
I called OleInitialize...
But I cant get the written error message... can someone help?
Well... I am a beginner ...
|
|
|
|
|
Without knowing the error (post the return value from CoCreateInstance() ) I can only guess, but the first parameter looks like an IID, not a CLSID. You need to put the CLSID of the WMP object there.
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
"Linux is good. It can do no wrong. It is open source so must be right. It has penguins. I want to eat your brain."
-- Paul Watson, Linux Zombie
|
|
|
|
|
...ok I fixed the classid thing like this:
<br />
CLSID idMediaPlayer;<br />
HRESULT hr = ::CLSIDFromProgID (L"WMPlayer.OCX.1", &idMediaPlayer);<br />
Well I was using windows media player 8 but I found that I jammed up the class-id... then I installed Windows Media Player 9...
The error code is: "REGDB_E_CLASSNOTREG" ...
I am not sure if I have to use "msdxm.ocx" for windows media player 9...
Well... I am a beginner ...
|
|
|
|
|
I have to use wmp.dll and WMPlayer.OCX.7 is just working fine thanks a lot!
Well... I am a beginner ...
|
|
|
|
|
Hy everyone!
My colleage wants to include a "foreign" dll in his C++ program (written in VC++ 6.0). He said he has added the path to the dll in the settings of VC++ 6.0.
In command he is able to run the executable when the dll is located in the same folder. But in VC++ it does not work throwing an error message telling the dll is not available.
What is he doing wrong because at the moment I cannot find out, because I did never work with version VC++ 6.0 (I did only work with Visual Studio 2003 and that's a little different).
So if someone of you could tell me what he has to do to make VC++ find the dll please let me know and I will forward the infos to him.
Thanks!
Stephan.
|
|
|
|
|
He can add his path to the Global PATH enviroment variable, or he can drop his dll in the project directory, cos this is the default directory when a program is launched from the IDE
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I am trying to create virtual serial port.
Can anybody please give me tutorial or code link on this subject.
Thank you
rony
|
|
|
|
|
Can please anyone teach me how to make a rich text control linked to a tree ctrl with 4 or more sub-items(in the tree control),The text in the rich text box must change when the user clicks on the different sub-items in the treel control, please give me detailed code help.Please.... Why is everyone so selfish to teach me such a small thing?
|
|
|
|