|
Thanks jhwurmbach,
Could you explain or describe how multiplication could be implemented as table look-up solution please?
regards,
George
|
|
|
|
|
Some more read material: Pentium Optimization Cross-Reference[^].
From the page: LEA is better than SHL on the Pentium because it pairs in both pipes, SHL pairs only in the U pipe.
Also, as CPallini pointed out, the document states that lea can be beneficial than mul only when multiplied by 2, 3, 4, 5, 7, 8, 9.
|
|
|
|
|
Thanks Rajesh,
I read through the related section you referred. Really good.
1.
MUL is implemented through SHL? My previous thought is CPU has an individual multiplication implementation, especially for values to multiply are not power of 2 (e.g. * 3);
2.
Why when multiplying "2, 3, 4, 5, 7, 8, 9" are better to use LEA? How do we get such numbers?
regards,
George
|
|
|
|
|
You need to understand how the effective address is calculated in x86 CPUs.
I'm not an expert, but from here[^]
The offset part of the memory address can be specified either directly as a static value (called a displacement) or through an address computation made up of one or more of the following components:
Displacement—An 8-, 16-, or 32-bit value.
Base—The value in a general-purpose register.
Index—The value in a general-purpose register except EBP.
Scale factor—A value of 2, 4, or 8 that is multiplied by the index value.
An effective address is computed by:
Offset = Base + (Index * Scale) + displacement
So the address generation logic provides a rapid way to compute B + I*S + D, (and this has to be very fast as it is done before the memory access) all the article was saying was that the LEA instruction allows the programmer to access the result of this instruction that clearly executes in one cycle, which back when the article was written, was presumably faster than using the integer ALU. Note that as the Scale factor is restricted to being 1,2,4 or 8 there are limited equations that can be calculated. To multiply by 5 you would calculate base + 4*base etc..
It may not be relevant today.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Thanks Peter,
I like the article and read through it last evening. Three more comments,
1.
I found two places in the document are conflicting, they are
- "Modern operating system and applications use the (unsegmented) memory model¾ all the segment registers are loaded with the same segment selector so that all memory references a program makes are to a single linear-address space." -- looks like segment is useless since unsegment model is used?
- "The offset which results from adding these components is called an effective address of the selected segment. Each of these components can have either a positive or negative (2's complement) value, with the exception of the scaling factor." -- why still needs segment selector to calculate? Conflicting with last statement, which is unsegment model?
2.
"Note that the value of the EIP may not match with the current instruction because of instruction prefetching. The only way to read the EIP is to execute a CALL instruction and then read the value of the return instruction pointer from the procedure stack." -- my confusion is, EIP is next instruction to execute, and why return address is the same as EIP? Are they related?
3.
"you generally create segment selectors with assembler directives and symbols. The assembler and/or linker then creates the actual segment selectors associated with these directives and symbols." -- what does this mean? Does it mean all segment related instruction will be ignored or modified by linker before execution?
regards,
George
|
|
|
|
|
hi all,
i have an application that installs a hook(WH_GETMESSAGE) that handles mouse events, in case of WM_MOUSEMOVE my application need a notification with the msg structure associated with WM_MOUSEMOVE. I tried SendMessage its not woking ( i think its because of msg is a pointer). is any other way to do this.
Thanks & Regards
|
|
|
|
|
|
Does this[^] helpful for you?
|
|
|
|
|
code for checking an Invalid IP address by using Regular expression,Validators and QLineEdit ? It should show the IP address dialog as ( . . . ) instead of (000.000.000.000).
(i hav done this by setting mask and creating a regular expression and after that setting the validator.. and it works but it shows the IP address dialog as i hav written above)
modified on Wednesday, July 16, 2008 6:59 AM
|
|
|
|
|
Well, good luck!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I was trying to figure out your question, or even find a question mark in your post, but I couldn't.
|
|
|
|
|
Can you more explain about your question?
|
|
|
|
|
hey hi, i hav done this by setting mask and creating a regular expression and after that setting the validator.. but it shows the result as 000.000.000.000 but i need that it should be like this ( . . . )
|
|
|
|
|
Hi all ,
i m using this code for hadling keys of keyboard for TreeCtrl.
Here i m use Space key and its working fine.
if i m use VK_RETURN in place ok VK_SPACE fro enter key than its not working,the messagebox not shaw at this time.Please correct me.
CTreeCtrl trCtrl;
void CTest::OnTvnKeydownReportTree(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTVKEYDOWN pTVKeyDown = reinterpret_cast<LPNMTVKEYDOWN>(pNMHDR);
NMTVKEYDOWN* nmkd = (NMTVKEYDOWN*)pNMHDR;
CString Tree_str;
switch(nmkd->wVKey)
{
case VK_SPACE:
HTREEITEM hItem = trCtrl.GetNextItem(TVI_ROOT, TVGN_CARET );
if (hItem == NULL)
{
AfxMessageBox(_T("There is no selected item);
}
else
{
Tree_str = trCtrl.GetItemText(hItem);
AfxMessageBox(Tree_str);
}
}
*pResult = 0;
}
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello everyone,
My question is during system shutdown/reboot, will OS shutdown/reboot wait for all process to terminate or not? How could OS identify if a process is terminated or not?
I am suffering a problem when write event log returns 0x80004005 error in my own code when system is reboot (I monitor this reboot in Event View), I think OS should always wait for process to complete (e.g. write event log operation) before stops event log services and reboot? Maybe OS does not wait until my process completed event log write?
thanks in advance,
George
|
|
|
|
|
George_George wrote: My question is during system shutdown/reboot, will OS shutdown/reboot wait for all process to terminate or not?
The OS will ask the applications to shut down, but if they don't after a timeout they'll be killed. Surely you've seen the dialog that informs you of this? A good starting point to find out about this process is the documentation for the WM_QUERYENDSESSION[^] message.
George_George wrote: How could OS identify if a process is terminated or not?
The OS manages processes and such so it's not hard to accept it can tell when a process is done. Anyway, you can use the WaitForSingleObject[^] function to tell is a process is done yourself (amongst other methods).
Steve
|
|
|
|
|
Thanks Steve,
I have a great reading for the links you recommended. Actually, my application does not handle WM_QUERYENDSESSION and WM_ENDSESSION. In my scenario, I do not call any system API to let system reboot, and I just press the reboot button from start menu.
My questions,
1.
If my application does not handle the two message types, OS will wait for only some time before shutdown? It means OS may stop event log services rudely (not waiting for process termination) before I write event log?
2.
The WM messages are for Windows Form application (I read the document that it mentioned it sends the message to each Window)? How about a backend service without any GUI?
3.
If I handle the WM_QUERYENDSESSION message (returns TRUE), and then received the WM_ENDSESSION message from OS, then from OS point of view, it will think when WM_ENDSESSION is sent, it will believe the process is stopped (even if the process may running)?
regards,
George
|
|
|
|
|
George_George wrote: My question is during system shutdown/reboot, will OS shutdown/reboot wait for all process to terminate or not
No exactly wait but after period it kills them for example some time you see a window a it has a button "end now".
|
|
|
|
|
Thanks Hamid!
Previously, I think event log is always ready even if during system reboot/shutdown process, so write event log during system reboot never fails (event log service should be the last service which system should stop before all other processes stop). Now, the correct conclusion should be, OS does not ensure the event log service is always avaliable during system reboot?
regards,
George
|
|
|
|
|
Hi all,
i m using ShellExecute function for open an .exe file in another application, i want to close the opened exe file plz tell me which function is for this.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
In general the only way to close an application is to ask it nicely. Although you could use TerminateProcess[^] doing so could be dangerous as the application could have been in the middle of something important and "killing" it could result in corruption. See here[^] for an article on how to terminate an application "cleanly" in Win32.
Steve
|
|
|
|
|
You can send WM_CLOSE to that program with SendMessage.
|
|
|
|
|
Hi all
I have a CTI application which handles calls to a contact centre . The issue is - the exe keeps consuming more and more memory day after day . For example - at the startup the memory usage is 80 Mb . And after several calls the memory raises to 114 Mb and goes on upto 480 Mb .
My question is
- How to find out the exact piece of code which is responsible for this accumulated usage ?
- This is a VB application which uses several C# and VC++ dlls in the back ground .
Any help please ...?
regards
Kanna
|
|
|
|
|
I understood your problem.It is the problem with the Memory leak.And also with the GDI leaks..
In task manager you just enable the GDI coloum and check weather it is increasing the count.If it is increasing the count then it is a GDI leak also there.It occurs when you dinamically create the object and you r not releasing while end of the function.
Same case witht the GDI also creating pen and brushes and other GDI objects you may not be relaeasing
|
|
|
|
|
Never had any idea you could track GDI objects in the task manager. You've just helped me identify the source of a memory leak in some code I'm working on.
Thank-you pallaka - 5 points!
|
|
|
|