|
Thanks Hamid,
I am interested in two points,
1.
"string returned in lpOut is not guaranteed to be NULL-terminated" -- can you show me a sample please? I do not know this.
2.
"avoid the %s format -- it can lead to a buffer overrun" -- also, could you show a sample please? Previously, I think it is safe.
regards,
George
|
|
|
|
|
George_George wrote: For example, wait for a handle (convenient to analyze deadlock), sleep, running? Since my application deals with I/O heavily, it is good if the tool could monitor I/O thread's status -- e.g. sent request, waiting response or something?
Thread Status Monitor from Object Media[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Looks like some 3rd party tool, are there any MS tools?
regards,
George
|
|
|
|
|
For such tools from MS, technet is the only place I can think of. If technet has nothing of that sort which would satisfy your needs, then there's probably no such tool from MS (I presume that you've searched technet for your requirement).
Just curious, is there a reason why you want it to be from MS?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks Rajesh!
If it is MS tool, I think more people will use it and more popular, so when I met with issues, I can come to forums to ask.
BTW: do you use the 3rd party tool on Windows Server 2003 x64? Do you think it is reliable?
regards,
George
|
|
|
|
|
I've personally not used it; but I've heard the tool is OK, from a colleague who had been using it. At least it is free.
See if this[^] helps as well.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thanks Rajesh,
I will try this tool.
regards,
George
|
|
|
|
|
I think its detail is limited,right?
|
|
|
|
|
Detail of what? What is the tool you are talking about?
regards,
George
|
|
|
|
|
No it was a reply to Rajesh .
|
|
|
|
|
I am not sure if I get your question right there. It just lets you know the thread status, context, etc., (refer to the image on the link I provided). It does not come with source code, but it is not a limited or a trial version.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Good.
regards,
George
|
|
|
|
|
Check this article Monitoring Threads[^]. You can either write a script or code it in c++.
-Saurabh
|
|
|
|
|
Thanks Saurabh,
I read it and it looks like PowerShell scripts. I think my requirement is common. There is no such existing tools?
regards,
George
|
|
|
|
|
Since you need to monitor threads you assume that your requirement is common. But that is not the case! What exactly are you trying to do anyway? Do you want to spy other processes or monitor you own process?
-Saurabh
|
|
|
|
|
Thanks Saurabh,
I am using admin. Why do you think monitor status for threads (wait, executing or something) is not common? Any performance analysis needs such tools.
regards,
George
|
|
|
|
|
What do you mean by "I am using admin"??
If I want to analyze performance of an application I will use a profiler. I have no control over how threads will be scheduled, for how long they have to wait, etc. Hence knowing how long my thread waits for IO will lead me nowhere w.r.t. optimization. On the other hand profiler will tell me how much time each function takes and how many times it is called during an execution. Using this I can try to optimized expensive and more frequently functions.
By the way, Rajesh gave you perfect tool for monitoring threads but still you insist on tool from MS because there will be more help for it. What kind of support do you expect from a tool which just shows thread information? I mean there is nothing more to it other than displaying thread information.
-Saurabh
|
|
|
|
|
Thanks Saurabh,
Help from your guys are good enough now.
regards,
George
|
|
|
|
|
George_George wrote: I am using admin
Can you more explain?
|
|
|
|
|
Thanks Hamid!
Sorry for my bad English. I mean I am using Administrator Group account to monitor, so no security concern.
Any ideas about how to monitor threads' status?
regards,
George
|
|
|
|
|
I have a dialog with 2 Date Time Picker.
The first is m_date with Short Date format
The second is m_time with Time format
CDateTimeCtrl dateBox;
CDateTimeCtrl timeBox;
Then I want to get the timestamp from them, the final result should be in __int64 (to compare with database and something else). An example is 1214878775000 for a SYSTEMTIME
wYear 2008
wMonth 7
wDayOfWeek
wDay 1
wHour 11
wMinute 19
wSecond 35
wMilliseconds 734
Try to look at the MSDN, there are many stupid things: CTime, SYSTEMTIME, FILETIME, .... blah blah .... with a alot of functions.
Is it really that difficult or I go the wrong way? Does anyone have some way to to this?
Here I got the result with a function like this way:
__int64 CMyDlg::getTimestamp()
{
__int64 nTime;
CTime tmpTime;
int nYear, nMonth, nDay, nHour, nMin, nSec;
dateBox.GetTime( tmpTime );
nYear = tmpTime.GetYear(); nMonth = tmpTime.GetMonth(); nDay = tmpTime.GetDay();
timeBox.GetTime( tmpTime );
nHour = tmpTime.GetHour(); nMin = tmpTime.GetMinute(); nSec = tmpTime.GetSecond();
CTime navTime( nYear, nMonth, nDay, nHour, nMin, nSec );
SYSTEMTIME ST;
FILETIME FT;
navTime.GetAsSystemTime(ST);
SystemTimeToFileTime(&ST,&FT);
__int64 nSetTime;
memcpy(&nSetTime, &FT, sizeof(FILETIME));
MyFormatter formatter;
nTime = formatter.FileTimeToJavaTime(nSetTime);
nTime -= 9 * 60 * 60* 1000;
return nTime;
}
It use another class MyFormatter that I cannot understand. I really hate these stupid stuff !!!
Does anyone have a simple way to get timestamp?
Thank you in advance,
|
|
|
|
|
While it's not completely portable, have you tried:
SystemTimeToFileTime(&ST,&FT);
__int64 *nTime = (__int64 *) &FT;
return *nTime;
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
thank you, DavidCrow
it works, and a little bit better. but I mean, here is the progress:
from dialog item -> CTime variable -> another CTime var -> SYSTEMTIME var -> FILETIME var -> __int64 result
well, I think it's too much. It's too complex for newbie in VC++, also. And the most is: is it really necessary to be like that???
Do you have a simplier solution for this?
Does anyone have?
thank you very much,
modified on Tuesday, July 1, 2008 1:17 AM
|
|
|
|
|
tataxin wrote: Do you have a simplier solution for this?
Not by much. What about:
__int64 CMyDlg::getTimestamp( void )
{
SYSTEMTIME stDate;
m_date.GetTime(&stDate);
SYSTEMTIME stTime;
m_time.GetTime(&stTime);
stDate.wHour = stTime.wHour;
stDate.wMinute = stTime.wMinute;
stDate.wSecond = stTime.wSecond;
FILETIME ft;
SystemTimeToFileTime(&stDate, &ft);
__int64 *nTime = (__int64 *) &ft;
return *nTime;
}
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Oh nice, DavidCrow!!
At least we don't have to use CTime. so the process will be
from dialog item -> SYSTEMTIME var -> FILETIME var -> __int64 result
It works,
Thank you very much!!
|
|
|
|