|
Rajesh R Subramanian wrote: while(2)//Be twice as confident!
hmmm....I don't agree. 2 in binary is still only 1 set bit.
I'd use 3 so if one of the bits fails there's another to fall back on.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
How CPU usage is calculated under windows?
- Vikram S
|
|
|
|
|
GetProcessMemoryInfo,GetSystemTimes and GetPerformanceInfo may be of some help.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I don't want the CPU usage but I am interested in knowing how it is calculated.
|
|
|
|
|
the API access the hardware directly...
|
|
|
|
|
Again I want to know
is there any formula which they use to calculate CPU usage.
As far I know any process can use either 0% or 100% CPU at specific instance. So as a result I wanted to know
1) Do they use some time frame to calculate CPU usage?
2) What about multi core systems? What is formula for calculating CPU usage for this kind of hardware?
|
|
|
|
|
Hi,
this will show you how it can be done.
Assume you go to the shopping mall; don't forget to carry your watch.
Note the entry time ("mallStart")
Now for an arbitrary number of iterations:
- choose a shop i
- note entry time ("istart")
- wander around
- note exit time ("istop")
At the end, note the time you leave the mall ("mallStop")
Now the total time was mallStop-mallStart
and the time spent in shop i was istop-istart (or if you went to shop i more than once, it
was sum of each of the istop minus sum of each of the istart)
And the fraction of time alloted to shop i was (istop-istart)/(mallStop-mallStart)
If you add all the fractions, you will end up less than one, the remainder is the time
spent in the mall but outside the shops, let us call it the idle time.
Now imagine you are a CPU, and the shops are the processes that need to run. There you go.
|
|
|
|
|
Thank you very much: now I understand why female processes take far more CPU time than male ones.
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]
|
|
|
|
|
|
Fix occurred here. Remember to feed your troll today.
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]
|
|
|
|
|
Thanks for the fix.
I think the troll's name should be uni-puke.
|
|
|
|
|
Thanks for detailed information !
|
|
|
|
|
I have derived my own custom class from MFC CTreeCtrl and using this arical
http://www.codeguru.com/cpp/control...ticle.php/c723/
I have made multiple tree selection possible. Now the problem comes while deleting multiple items. I am finding it very complex logically.
The problem is while deleting multiple items, [B][I]"if one of the selected items is a child item and its parent is deleted first, then all the children will be deleted too and all the information about the deleted item will be lost."[I][B].
Can someone help me in finding a good solution? Thanks in advance
Maverick
|
|
|
|
|
you can delete the selected children first. If after deletion you have some nodes that are still existing you don't delete the parent else you can delete it. You can implement a recursive function for this.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I don't found any article in the specified link.
Here one thing is not clear :
do you want to delete multiple tree items at one shot?
If this is the case than,
when a parent and a child is selected of the same node or parent of one node and child of the other node? it's a not valid selection for deletion,if multiple selection is selected in a tree control.
|
|
|
|
|
http://www.codeguru.com/cpp/controls/treeview/misc-advanced/article.php
This is the Link. Surprising it didn't open in your case. This artical is only helpful in selecting multiple items in CTreeView control because MFC does'nt provide functionality to select multiple items in a TreeView Control.
Yes the aim is to delete multiple Tree Items in one shot and there are possibilities in which parents and childs of same catagory are selected, and this problem is arising because of this selection only, that if one of the selected items is a child item and its parent is deleted first, then all the children will be deleted too and all the information about the deleted item will be lost.
If you are saying that its not a valid selection then what restriction should I impose while selecting an item? What should be the valid selection criteria for multiple item deletion according to users point of view??
Maverick
modified on Monday, July 28, 2008 6:36 AM
|
|
|
|
|
Ok,
The simplest thing i can suggest is that on click of delete, iterate through all selections ,if any selected node is not child one than display a message saying all parents should be selected.. or any thing to the user saying it's not a valid selection.
Regards,
KDevloper
|
|
|
|
|
Well I am afraid that it was requirement from the client that the multiple selection can be of any sort, so I have to deal with it that way I can't display any message.
Maverick
|
|
|
|
|
I'm using VC++ 6.0;
Suppose a variable is declared in a DLL and there are two functions exported from the DLL. 1st function initializes the variable and the other one accesses it. Is it possible to call first function from one application and call second function from another application to access it? I have tried declaring a static/global variable but it loses initialized value when accessed from 2nd application. #pragma doesn't seem to work as well..
Anyone having any clue about the issue please respond.
Thanks and regards.
R.
|
|
|
|
|
probably you need shared memory or you can do it using CreateFileMapping or you can use IPC
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
See here.
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]
|
|
|
|
|
well, my compiler gave the following warning:
D:\Testing\testpos\caller.cpp [Warning] `allocate' attribute directive ignored
and after initializing in 1st app the value that I get in 2nd app is 0
I also tried
#pragma data_seg("SHARED")
int i; // 'i' will be initialized later with function1
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")
but that also gives initialized value in the frst app but gives 0 when accessed from 2nd app.
|
|
|
|
|
Did you read the linked page of my post?
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]
|
|
|
|
|
|
Hi,
Q1.
I renamed my class name from FRWS to HELPER in order to combine all my "helper" classs into one HELPER CLASS; otherwise I will have a lot of small classes and long list of imports.
when I compile my prog, I get this error:
error C2533: 'FRWS::{ctor}' : constructors not allowed a return type
Q2.
When I try to use this object in the main program,
FRWS Sbj;
i get these errors:-
error C2065: 'FRWS' : undeclared identifier
error C2146: syntax error : missing ';' before identifier 'Sbj'
Enclose is the code:-
[HELPER.H was formally FRWS.H]
[contains 2 different classes]
#pragma once
class FRWS {
public:
FRWS(void);
virtual ~FRWS(void);
public:
CString ETEXT(CString givenTEXT);
CString DTEXT(CString givenTEXT);
};
class pgLog {
public:
pgLog(void);
virtual ~pgLog(void);
public:
void WLog( CString TF, CString LgText );
}
[THIS IS HELPER.CPP]
#include "StdAfx.h"
#include "Helper.h"
FRWS::FRWS(void) {
}
FRWS::~FRWS(void) {
}
CString FRWS::ETEXT(CString givenTEXT){
...
}
CString FRWS::DTEXT(CString givenTEXT){
...
}
void pgLOG::WLog( CString TF, CString LgText ){
...
}
|
|
|
|