Re: Relationship between Application.Exit() and AppDomain

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Jeffrey,

See inline.

Willy.

""Jeffrey Tan[MSFT]"" <jetan@xxxxxxxxxxxxxxxxxxxx> wrote in message news:$PxWyWGoIHA.9016@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi Willy ,

This sounds like a promising explanation. Thank you for the sharing.

Well, actually I'm not so sure it's a valid explanation, especially because I can't seem to repro the issue, even not when running four threads on a quad-core running Vista SP1.

However, from principle, I am still a bit hard to understand it. The
started worker threads should run under the same priority as the GUI
threads. Even on the single-core CPU, OS kernel thread schedular will give
each thread the same time slice as long as these threads are in the same
priority. It is hard for me to understand why the CPU gives not enough time
to the GUI thread to call Thread.Abort() method.


Apparently there is a dedicated thread that serves to unload AD's in V2 (see the "Remarks" section in the AppDomain.Unload description), that means that AD Unloads are not executed on the UI thread. I assume they would use the Finalizer thread for this, but I can't confirm this for sure.


Furthermore, if I remember correctly, the CPU will boost the UI thread's
priority making it more user friendly. So the GUI thread should have higher
priority(at least a small period) to execute the Thread.Abort() method.

True, but irrelevant when the Thread.Abort is issued by another (the dedicated) thread that runs with "normal" priority level., if it's done by the finalizer thread then there shouldn't be an issue as this one run at real-time priority level.


Additionally, since the Thread.Abort() will cause the user-mode to
kernel-mode transition with stack-unwind which are both very consuming, I
suspect if this is another important factor for AppDomain.Unload() expires.

Anyway, I agree that real-world seldom causes this problem. Catching this
CannotUnloadAppDomainException and call AppDomain.Unload() again should
resolve this problem.


Best regards,
Jeffrey Tan
Microsoft Online Community Support
=========================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx

This posting is provided "AS IS" with no warranties, and confers no rights.




.



Relevant Pages

  • [PATCH][RSDL-mm 5/6] sched: implement rsdl cpu scheduler
    ... Rotating Staircase Deadline cpu scheduler policy ... A novel design which incorporates a foreground-background descending priority ... RSDL works off the principle of providing each task a quota of runtime that it ... that priority level to the next lowest priority level. ...
    (Linux-Kernel)
  • Re: profiler which does not just sum up used time
    ... As said in another reply, the real-time priority class will put all threads in the process in the real-time range, a couple of system threads may be running at level 31, the system can even run threads at an interrupt request level that prevents other threads to run. ... As I said before, Windows is not a real-time OS, you have no control over the thread scheduler other than increasing the relative priority level of one user thread over another user thread, but you won't be able to stop the scheduler to prevent pre-emption of your thread, so you can't achieve what you want on Windows, that is, running a thread on a single core without being interrupted or pre-empted, you can't even prevent being re-scheduled on another core. ... // run this part of code at a priority level defined by the "Pro Audio" task. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Relationship between Application.Exit() and AppDomain
    ... started worker threads should run under the same priority as the GUI ... Even on the single-core CPU, OS kernel thread schedular will give ... to the GUI thread to call Thread.Abortmethod. ... You can send feedback directly to my manager at: ...
    (microsoft.public.dotnet.framework.clr)
  • Re: priority inheritance (Tornado 202)
    ... only mutex semaphores allow priority inheritance. ... when the inherited priority level is ... lock on the mutex semaphore gives up its last inversion safe mutex ...
    (comp.os.vxworks)
  • Re: IDirect3DResource9::SetPriority... What are the priority levels
    ... > In the IDirect3DResource9::SetPriority call, what does the priority level ... A resource assigned a low priority is removed before a resource ... "Texture priorities are used as tie breakers when two textures are targeted ...
    (microsoft.public.win32.programmer.directx.graphics)