Re: .NET Poor threading architecture?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"WXS" <WXS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:77230348-7B5E-4874-8C74-716E79D5420D@xxxxxxxxxxxxxxxx
|> Suspend/Resume are made obsolete just because of this "the willingness to
| > correct". These API's are calling the Win32 counterparts which are:
| > - not designed to be used from user code [see MSDN - SuspendThread API
<This
| > function is primarily designed for use by debuggers. It is not intended
to
| > be used for thread synchronization>]
|
| >>>> These Win32 API's have been used for years (not for thread
synchronization), but for thread control (forget synchronization that is not
the intention, thread control is). By default threads are suspended and
must be resumed and the MFC/Win32 level for example which is used in almost
all threading cases. User code uses them all the time.
| You need to be able to control your threads in .NET for various reasons,
| these API's are sometimes critical and the only means for a developer to
| accomplish specific functionality. I think they should make them so
suspend
| would stop the thread at a safe point from .NET's perspective and leave
the
| rest of the safety to the developer.

This is exactly what the CLR does, calling 'SuspendThread' and
'ResumeThread' at a safe spot, but that doesn't mean it has to be done from
"managed" user code that runs in top of the CLR.
When using MFC and Win32 you are at a different level in user space, using
Win32 you are directly controlling OS threads from your code (just like the
CLR does), when you call SuspendThread you ask the OS to suspend the OS
thread, you are assumed to know the pittfals and take measures to prevent
all sort of issues and bugs (T in Threading spell for Troubles, most of the
multithreaded applications are buggy). In managed code you aren't controling
(nor should you) OS threads, you are using "logical threads" that map to
something that might be an OS thread, but can even so be something else
(like a fiber). IMO it's up to the CLR and the FCL to make threading less
error prone and more (safely) accessible than under native code, so it's
better to remove these services, provided there are more safe alternatives,
as there are.


| > As for your suggestion to make WinFX the primary OS API, don't forget
that
|
| >>>> That's not my suggestion I heard MS has proposed that will be the
case in a future OS version. I agree with you... it is unreasonable.

Really, any signs that David Cutler going to retire? :-)) Mind to share the
source of such proposition? I know that Vista and Longhorn Server are still
Win32 based. IMO Win32 will survive the CLR, but as always - only the future
will tell.


Willy.


.



Relevant Pages

  • Re: .NET Poor threading architecture?
    ... | First point is my understanding is suspending is not safe even from a CLR ... Well largely it relates to GC, but the CLR uses these Win32 API's to control ... exactly when to suspend because the JIT marks the safe points to do so. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: .NET Poor threading architecture?
    ... NO it doesn't, these Win32 services are considered dangerous, designed to be ... integrated the CLR, they don't allow you creating threads in managed code ... | a safe way, and suspend should suspend when safe for the CLR runtime, it ... | please don't hide the emergency break in my car because you think I might ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: System Timer Callback?
    ... This is not specifically about the MCI control, ... functions that suspend the event processing, leading to a very Ad Hoc ... collection of loops containing "DoEvents". ... Asynchronous normally means it moves everything off to a background thread and allows your code to carry on as before, but there are some exceptions that will just call Doevents allowing other code to run, but STILL blocking your thread of execution. ...
    (microsoft.public.vb.general.discussion)
  • Re: hitting C-s
    ... I'm assuming C-s is for suspend. ... ASCII control characters has virtually no mnemonic association. ... could have a Paper Tape reader and a Paper Tape punch. ...
    (comp.unix.questions)
  • Re: Encase Forensic
    ... Somebody suspend the diverse producer and organise it ... One more secure wells incur Abdellah, ...
    (sci.crypt)