473,395 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

CreateApplicationContext thread take 50% cpu

Hi,

When I start my application, I notice that it takes 50% CPU in idle status
!
I used Process Explorer from Sysinternals to find what thread is consuming
that much CPU.
Only 1 thread is consuming the whole 50% : "mscorwks.dll!
CreateApplicationContext".

To be complete :
.. I am using VS2005 (=> dotnet framework 2.0)
.. my application is calling a dll written in C# dotnet framework 1.1 that
is a wrapper for C++ legacy code handling a serial port
.. my application previous version written in dotnet framework 1.1 used the
same wrapper code (but not via a dll), cpu was almost 0 in this case.

Thanks a lot in advance for your help.

Droopy.
Apr 10 '06 #1
9 6788

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.72...
| Hi,
|
| When I start my application, I notice that it takes 50% CPU in idle status
| !
| I used Process Explorer from Sysinternals to find what thread is consuming
| that much CPU.
| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| CreateApplicationContext".
|
| To be complete :
| . I am using VS2005 (=> dotnet framework 2.0)
| . my application is calling a dll written in C# dotnet framework 1.1 that
| is a wrapper for C++ legacy code handling a serial port
| . my application previous version written in dotnet framework 1.1 used the
| same wrapper code (but not via a dll), cpu was almost 0 in this case.
|
| Thanks a lot in advance for your help.
|
| Droopy.
Do you mean that your application keeps consuming 50% of the CPU while
executing the CreateApplicationContext function?
What happens if you compile your wrapper DLL using vs2005?

Willy.

Apr 10 '06 #2
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
news:Ok**************@TK2MSFTNGP03.phx.gbl:

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.72...
| Hi,
|
| When I start my application, I notice that it takes 50% CPU in idle
| status !
| I used Process Explorer from Sysinternals to find what thread is
| consuming that much CPU.
| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| CreateApplicationContext".
|
| To be complete :
| . I am using VS2005 (=> dotnet framework 2.0)
| . my application is calling a dll written in C# dotnet framework 1.1
| that is a wrapper for C++ legacy code handling a serial port
| . my application previous version written in dotnet framework 1.1
| used the same wrapper code (but not via a dll), cpu was almost 0 in
| this case.
|
| Thanks a lot in advance for your help.
|
| Droopy.
Do you mean that your application keeps consuming 50% of the CPU while
executing the CreateApplicationContext function?
Yes !
What happens if you compile your wrapper DLL using vs2005?

Well I don't know !
I compiled it in vs2003 because the C++ wrapper did not compile in
vs2005.
It seems there are a lot of changes concerning C++ managed extensions and
I did not have enough time to port it (at least I expected it to be non
easy).
Willy.


Thanks a lot for your help.
Apr 11 '06 #3

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.72...
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| news:Ok**************@TK2MSFTNGP03.phx.gbl:
|
| >
| > "Droopy" <dr**************@hotmail.com> wrote in message
| > news:Xn**********************************@195.129. 110.72...
| >| Hi,
| >|
| >| When I start my application, I notice that it takes 50% CPU in idle
| >| status !
| >| I used Process Explorer from Sysinternals to find what thread is
| >| consuming that much CPU.
| >| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| >| CreateApplicationContext".
| >|
| >| To be complete :
| >| . I am using VS2005 (=> dotnet framework 2.0)
| >| . my application is calling a dll written in C# dotnet framework 1.1
| >| that is a wrapper for C++ legacy code handling a serial port
| >| . my application previous version written in dotnet framework 1.1
| >| used the same wrapper code (but not via a dll), cpu was almost 0 in
| >| this case.
| >|
| >| Thanks a lot in advance for your help.
| >|
| >| Droopy.
| >
| >
| > Do you mean that your application keeps consuming 50% of the CPU while
| > executing the CreateApplicationContext function?
|
| Yes !
|

Well, that would mean that this function never returns, more, it loops
endlessly, which IMO is not quite possible. Only possible way to know for
sure what's happening is to attach a debugger (native mode).

Willy.
Apr 11 '06 #4
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
news:ON**************@TK2MSFTNGP04.phx.gbl:

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.72...
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| news:Ok**************@TK2MSFTNGP03.phx.gbl:
|
| >
| > "Droopy" <dr**************@hotmail.com> wrote in message
| > news:Xn**********************************@195.129. 110.72...
| >| Hi,
| >|
| >| When I start my application, I notice that it takes 50% CPU in
| >| idle status !
| >| I used Process Explorer from Sysinternals to find what thread is
| >| consuming that much CPU.
| >| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| >| CreateApplicationContext".
| >|
| >| To be complete :
| >| . I am using VS2005 (=> dotnet framework 2.0)
| >| . my application is calling a dll written in C# dotnet framework
| >| 1.1 that is a wrapper for C++ legacy code handling a serial port
| >| . my application previous version written in dotnet framework 1.1
| >| used the same wrapper code (but not via a dll), cpu was almost 0
| >| in this case.
| >|
| >| Thanks a lot in advance for your help.
| >|
| >| Droopy.
| >
| >
| > Do you mean that your application keeps consuming 50% of the CPU
| > while executing the CreateApplicationContext function?
|
| Yes !
|

Well, that would mean that this function never returns, more, it loops
endlessly, which IMO is not quite possible. Only possible way to know
for sure what's happening is to attach a debugger (native mode).

Willy.


Not sure I understand !
I didn't call this function so how can I check if it returns ?
By the way, I have the whole source code so I can start the application
in debug mode in vs2005.
Should I put a breakpoint somewhere ?
Apr 12 '06 #5

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71...
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| news:ON**************@TK2MSFTNGP04.phx.gbl:
|
| >
| > "Droopy" <dr**************@hotmail.com> wrote in message
| > news:Xn**********************************@195.129. 110.72...
| >| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| >| news:Ok**************@TK2MSFTNGP03.phx.gbl:
| >|
| >| >
| >| > "Droopy" <dr**************@hotmail.com> wrote in message
| >| > news:Xn**********************************@195.129. 110.72...
| >| >| Hi,
| >| >|
| >| >| When I start my application, I notice that it takes 50% CPU in
| >| >| idle status !
| >| >| I used Process Explorer from Sysinternals to find what thread is
| >| >| consuming that much CPU.
| >| >| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| >| >| CreateApplicationContext".
| >| >|
| >| >| To be complete :
| >| >| . I am using VS2005 (=> dotnet framework 2.0)
| >| >| . my application is calling a dll written in C# dotnet framework
| >| >| 1.1 that is a wrapper for C++ legacy code handling a serial port
| >| >| . my application previous version written in dotnet framework 1.1
| >| >| used the same wrapper code (but not via a dll), cpu was almost 0
| >| >| in this case.
| >| >|
| >| >| Thanks a lot in advance for your help.
| >| >|
| >| >| Droopy.
| >| >
| >| >
| >| > Do you mean that your application keeps consuming 50% of the CPU
| >| > while executing the CreateApplicationContext function?
| >|
| >| Yes !
| >|
| >
| > Well, that would mean that this function never returns, more, it loops
| > endlessly, which IMO is not quite possible. Only possible way to know
| > for sure what's happening is to attach a debugger (native mode).
| >
| > Willy.
| >
| >
| >
|
| Not sure I understand !
| I didn't call this function so how can I check if it returns ?
| By the way, I have the whole source code so I can start the application
| in debug mode in vs2005.
| Should I put a breakpoint somewhere ?

Ok, I suppose that your application doesn't run, right? That means it's
looping indefinitely without ever doing what it is supposed to do. If this
is not the case forget all that follows, and forget about Process explorer,
use a debugger or permon to watch CPU consumption, PE is not the right tool
for this.

Now, CreateApplicationContext is called by Fusion whenever classes are to be
loaded in an AD. So it can happen very early in the process when the CLR
loads system classes into the shared domain, that is before the JIT is
loaded. However I don't believe this is the case here.

The only way to set a breakpoint at mscorwks!CreateApplicationContext, is by
starting the application in an unmanaged debugger like Windbg. All you need
is a correct setup of the debugger environment and the symbol files.

But before you go down that route, run the application in the VS debugger,
if the function doesn't return (which I doubt) the application will loop, so
when you break you are sure you are in the mscorwks!CreateApplicationContext
native code (make sure you have the symbol path set to the symbol server -
http://msdl.microsoft.com/download/symbols ) and you can single step and
watch if it's effectively looping, if it does you will need to be a debugger
expert to be able to draw a conclusion.
Therefore I would suggest you take a close look at your code, compile the
wrapper using VS2005 and try again.
Willy.
Apr 12 '06 #6
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
news:#d**************@TK2MSFTNGP03.phx.gbl:

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71...
| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| news:ON**************@TK2MSFTNGP04.phx.gbl:
|
| >
| > "Droopy" <dr**************@hotmail.com> wrote in message
| > news:Xn**********************************@195.129. 110.72...
| >| "Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
| >| news:Ok**************@TK2MSFTNGP03.phx.gbl:
| >|
| >| >
| >| > "Droopy" <dr**************@hotmail.com> wrote in message
| >| > news:Xn**********************************@195.129. 110.72...
| >| >| Hi,
| >| >|
| >| >| When I start my application, I notice that it takes 50% CPU in
| >| >| idle status !
| >| >| I used Process Explorer from Sysinternals to find what thread
| >| >| is consuming that much CPU.
| >| >| Only 1 thread is consuming the whole 50% : "mscorwks.dll!
| >| >| CreateApplicationContext".
| >| >|
| >| >| To be complete :
| >| >| . I am using VS2005 (=> dotnet framework 2.0)
| >| >| . my application is calling a dll written in C# dotnet
| >| >| framework 1.1 that is a wrapper for C++ legacy code handling a
| >| >| serial port . my application previous version written in dotnet
| >| >| framework 1.1 used the same wrapper code (but not via a dll),
| >| >| cpu was almost 0 in this case.
| >| >|
| >| >| Thanks a lot in advance for your help.
| >| >|
| >| >| Droopy.
| >| >
| >| >
| >| > Do you mean that your application keeps consuming 50% of the CPU
| >| > while executing the CreateApplicationContext function?
| >|
| >| Yes !
| >|
| >
| > Well, that would mean that this function never returns, more, it
| > loops endlessly, which IMO is not quite possible. Only possible way
| > to know for sure what's happening is to attach a debugger (native
| > mode).
| >
| > Willy.
| >
| >
| >
|
| Not sure I understand !
| I didn't call this function so how can I check if it returns ?
| By the way, I have the whole source code so I can start the
| application in debug mode in vs2005.
| Should I put a breakpoint somewhere ?

Ok, I suppose that your application doesn't run, right?
No, it runs very well.
That means it's looping indefinitely without ever doing what it is supposed to do. If this is not the case forget all that follows, and forget about
Process explorer, use a debugger or permon to watch CPU consumption,
PE is not the right tool for this.

I used PE just to know which threads were consuming CPU but may be the
informations are not accurate.
Anyway%, both TaskManager and PE reports 50% cpu for the process.
Did you mean perfmon ?
I tried with it.
Not sure to use in the appropriate way.
I choose Thread/% Processor Time and one by one my application threads
until i choose one thread that report an average of 99,605 % !
I suppose is not % because task manager reports 50% cpu for the
application.
I can also run it into WinDbg but when I choose View/Processes and Threads,
the window is empty.

May be the best would be to try to recompile my application in vs2003
1) using my wrapper DLL
2) not using DLL (using the wrapper project)
Now, CreateApplicationContext is called by Fusion whenever classes are
to be loaded in an AD. So it can happen very early in the process when
the CLR loads system classes into the shared domain, that is before
the JIT is loaded. However I don't believe this is the case here.

The only way to set a breakpoint at mscorwks!CreateApplicationContext,
is by starting the application in an unmanaged debugger like Windbg.
All you need is a correct setup of the debugger environment and the
symbol files.

But before you go down that route, run the application in the VS
debugger, if the function doesn't return (which I doubt) the
application will loop, so when you break you are sure you are in the
mscorwks!CreateApplicationContext native code (make sure you have the
symbol path set to the symbol server -
http://msdl.microsoft.com/download/symbols ) and you can single step
and watch if it's effectively looping, if it does you will need to be
a debugger expert to be able to draw a conclusion.
Therefore I would suggest you take a close look at your code, compile
the wrapper using VS2005 and try again.
Willy.


Apr 13 '06 #7
> May be the best would be to try to recompile my application in vs2003
1) using my wrapper DLL
2) not using DLL (using the wrapper project)


I did it and still 50% CPU but this time PE reports it in mscorwks.dll!
ReleaseFusionInterfaces.

I made a new solution in vs2003 with 2 projects :
1) WinForm ported from vs2005
2) the wrapper project (not the dll).

So it seems that it is not linked to the wrapper project/dll because using
this same project wrapper in my previous program developped in vs2003 use
0% CPU.
Still, if I configure my application for not using serial ports (handled in
this wrapper project), the CPU usage is 0% !

I am puzzled.
Apr 13 '06 #8

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71...
|> May be the best would be to try to recompile my application in vs2003
| > 1) using my wrapper DLL
| > 2) not using DLL (using the wrapper project)
| >
|
| I did it and still 50% CPU but this time PE reports it in mscorwks.dll!
| ReleaseFusionInterfaces.
|

That's the last function called by fusion, but that doesn't mean this
function is still running.
| I made a new solution in vs2003 with 2 projects :
| 1) WinForm ported from vs2005
| 2) the wrapper project (not the dll).
|
| So it seems that it is not linked to the wrapper project/dll because using
| this same project wrapper in my previous program developped in vs2003 use
| 0% CPU.
| Still, if I configure my application for not using serial ports (handled
in
| this wrapper project), the CPU usage is 0% !
|
| I am puzzled.
Well, it looks like the Serial port C++ code is the culprit, apparently this
code runs on a thread other than the main thread (one that you created),
this one is in a tied loop. You don't call C functions in a loop don't you?

Willy.
Apr 13 '06 #9
"Willy Denoyette [MVP]" <wi*************@telenet.be> wrote in
news:#R**************@TK2MSFTNGP05.phx.gbl:

"Droopy" <dr**************@hotmail.com> wrote in message
news:Xn**********************************@195.129. 110.71...
|> May be the best would be to try to recompile my application in
|> vs2003
| > 1) using my wrapper DLL
| > 2) not using DLL (using the wrapper project)
| >
|
| I did it and still 50% CPU but this time PE reports it in
| mscorwks.dll! ReleaseFusionInterfaces.
|

That's the last function called by fusion, but that doesn't mean this
function is still running.
| I made a new solution in vs2003 with 2 projects :
| 1) WinForm ported from vs2005
| 2) the wrapper project (not the dll).
|
| So it seems that it is not linked to the wrapper project/dll because
| using this same project wrapper in my previous program developped in
| vs2003 use 0% CPU.
| Still, if I configure my application for not using serial ports
| (handled
in
| this wrapper project), the CPU usage is 0% !
|
| I am puzzled.
Well, it looks like the Serial port C++ code is the culprit,
apparently this code runs on a thread other than the main thread (one
that you created), this one is in a tied loop. You don't call C
functions in a loop don't you?

Willy.


No it can't because the same C++ code is executed in both version from my
application.
I added a lot of monitoring and finally found the bug :-)
Each time a message come from the serial line, I insert it in a queue to
give control back as soon as possible to calling thread.
Another thread is reading the queue and handle messages.
This handling is controlled by a ManualResetEvent.
Due to a bad indentation, this event was never Reset (Reset was just
outside the main loop) so the main loop was consuming all the CPU.

Anyway, thanks a lot for your help.
Apr 14 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: adeger | last post by:
Having trouble with my first forays into threads. Basically, the threads don't seem to be working in parallel (or you might say are blocking). I've boiled my problems to the following short code...
4
by: Gilles Leblanc | last post by:
Hi I have started a small project with PyOpenGL. I am wondering what are the options for a GUI. So far I checked PyUI but it has some problems with 3d rendering outside the Windows platform. I...
7
by: Ivan | last post by:
Hi I have following problem: I'm creating two threads who are performing some tasks. When one thread finished I would like to restart her again (e.g. new job). Following example demonstrates...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
5
by: Razzie | last post by:
Hi all, A question from someone on a website got me thinking about this, and I wondered if anyone could explain this. A System.Threading.Timer object is garbage collected if it has no...
16
by: droopytoon | last post by:
Hi, I start a new thread (previous one was "thread timing") because I have isolated my problem. It has nothing to do with calling unmanaged C++ code (I removed it in a test application). I...
9
by: mareal | last post by:
I have noticed how the thread I created just stops running. I have added several exceptions to the thread System.Threading.SynchronizationLockException System.Threading.ThreadAbortException...
13
by: Bob Day | last post by:
Using vs2003, vb.net I start a thread, giving it a name before start. Code snippet: 'give each thread a unique name (for later identification) Trunk_Thread.Name = "Trunk_0_Thread" ' allow...
7
by: Charles Law | last post by:
My first thought was to call WorkerThread.Suspend but the help cautions against this (for good reason) because the caller has no control over where the thread actually stops, and it might have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.