xiong's profile共享空间标题PhotosBlogLists Tools Help
    September 28

    DCOM/COM+ "Logic thread" "causality" "reentry" “Concurrency" NTA

    DCOM/COM+ "Logic thread" "causality" "reentry" “Concurrency" NTA
     
    Guidelines to help understand it:
     
    STA thread needs to pump message. It is important, but there is no need for you to over consider it. You just need to ensure your function does not block the message loop. When you make an outbound COM call, COM runtime helps maintain the loop, not your job.
     
    COM runtime keeps message loop for outbound call in STA thread. COM runtime does NOT keep message loop for outbound call in MTA thread.
     
    In regular STA COM component, message loop decides everything. If message loop runs, any call is able to come in if the COM STA component lives in this thread. Reentry is NOT a special case.
    Causality is not designed for COM or COM+. It exists in RPC layer.
     
    In regular COM, causality exists, but it does not affect COM behavior. Causality only affects in COM+ when COM+ Concurrency is considered.
     
    When COM+ requires Concurrency, we have a process wide lock in client. When you tried to enter an activity while the causality is different, the call will be rejected with error.
     
    The host may use any kind of to support STA thread pool. For example, COM+ uses STA thread pool by default. For singleton STA component, you will find multiple STA threads are executing with the same this pointer. For ATL DCOM, you can use CAtlAutoThreadModuleT to support thread pool.
     
    Thread pool model affects behavior. If single STA thread is used to host STA COM objects, when reentry occurs, the calls are placed in the single thread with FILO way. If host supports STA thread pool, the reentry may be dispatched to separate thread, and executes simultaneously.
     
    COM+ design goal is different from regular COM. Regular STA COM is designed to kill DLL hell as function call, status maintained, and thread safe. COM+ is designed as enterprise service supported with large scalability. You can play with COM, but COM+. One client, one NTA object, one job, one Causality, status less, never callback, never pass object pointer, are the best practice for COM+

    最近这几个名词快把我给弄死了。一个挖石油的,你管这么多干啥。特别是那个causality,整个互联网上只有Don Box的一片文章说到了这个东西,写作时间还是99年5月。现在都06年了,也没人弄清楚到底是个啥
     
     
    整个业界里面介绍COM+的书不少,但是烂书更多。大致把"causality", “Concurrency"说清楚估计就两本:
     
    O'Reilly - COM and .NET Component Services
    Transactional COM+ : Building Scalable Applications
     
    但是我保证这些资料也就能让您弄明白这玩艺是什么意思,怎么用,我至今也没看到资料。
     
     
    有一个客户端CLR WinForm程序,一个DCOM。DCOM暴露了一个event, WinForm用connection point的方法来订阅(subscribe)这个event。另外还有一个单独的程序(叫做程序A好了),负责让DCOM触发(fire)这个event。这个架构很标准对吧。
     
    当event fire的时候,客户端WinForm程序的某个方法就会执行。这个执行链接就是:
     
    程序A -----> DCOM ------>客户端WinForm
     
    现在客户端WinForm的响应方法里面,弹了一个MessageBox,现在我一直都不去点这个MessageBox
    接下来说一下问题:
     
    1. 程序A有没有hang在那里
    2. 如果再启动一个程序A的进程,那个进程能再发一个event到那个DCOM里面吗?
    3. DCOM会收到这个event的触发调用吗?还是会通过返回错误的方法立刻拒绝?还是先block在那里
    4. 如果DCOM会受到这个触发调用,DCOM通过connection point去调用客户端WinForm的响应方法吗?
    5. 如果DCOM决定调用,客户端会看到两个MessageBox吗?
     
    事实是,程序A hang了。如果再启动一个程序A的进程,这一串调用会成功,而且会看到两个MessageBox。
    如果你还不觉得很神奇,那我继续问:
     
    1. 实现event source的DCOM object要是singleton对吧。这个STA object怎么可以同时执行两个调用呢?
    2. 客户段的第二个MessageBox怎么出来的?在新的线程里面执行的?
    3. 出现两个MessageBox的时候,如果点掉第一个MessageBox,保留第二个MessageBox,程序A的hang会解除吗?
     
    还不够神奇的话,请把这个DCOM的代码编译成DLL,放到COM+里面去看看,结论一样吗?
     
    我本来想解释一下的。不过我现在终于明白为什么没有资料把这个东西解释清楚了。因为只有两种情况:
     
    1) 当你需要思考这个东西的时候,你肯定会自己去测试,因为不看到callstack,一切都是白说
    2) 如果你根本就没有思考过这个东西,我说了你也不懂
     
    所以,你才看到了文章前面那一大段我的洋文总结,而不是细致的带callstack的分析
     
     

    Comments (8)

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Sept. 8
    No namewrote:

    Amberdigital Branch,Southern Stars Enterprises Co is specializing in the development and manufacturing of mp4 advertisement players, SD card players and advertisement LCD displays. Established in 1996, we have explored and developed the international market with professionalism. We have built a widespread marketing network, and set up a capable management team dedicated to provide beyond-expectation services to our customers.

    amberdigital Contact Us
    Southern Stars Enterprises Co (Hong Kong Office)
    Add:3 Fl, No.2, Lane 2, Kam Tsin Tsuen, Sheung Shui, Hong Kong
    Tel:+852 2681 4099
    Fax:+852 2681 4586

    Southern Stars Enterprises Co (Shenzhen Office)
    Add:DE, 16/F, Building 2, Nanguo Tower, Sungang Road, Shenzhen, China
    Tel:+86 755 2592 9100
    Fax:+86 755 2592 7171

    E-mail:sstar@netvigator.com
    website:www.amberdigital.com.hk
    alibaba:amberdigital.en.alibaba.com[c

    Aug. 28
    No namewrote:
    wow gold!All wow gold US Server 24.99$/1000G on sell! Cheap wow gold,wow gold,wow gold,Buy Cheapest/Safe/Fast WoW US EU wow gold Power leveling wow gold from the time you World of Warcraft gold ordered! wow power leveling wow power leveling power leveling wow power leveling wow powerleveling wow power levelingcheap wow power leveling wow power leveling buy wow power leveling wow power leveling buy power leveling wow power leveling cheap power leveling wow power leveling wow power leveling wow power leveling wow powerleveling wow power leveling power leveling wow power leveling wow powerleveling wow power leveling buy rolex cheap rolex wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow gold wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling wow power leveling -316929420123698
    June 21
    Jan. 17
    Jan. 17
    xiong liwrote:
    这些分析都是不需要private symbol的。只需要看thread就可以了
    第三部分估计还要过个把月才完成,最近忙死累死,么时间啊
    Sept. 29
    方枪枪wrote:
    step from 1 to 5, question from 1 to 3,如果你也没有symbol和source code,呵呵,估计也会发晕。SY系统的人比较BT,扁他们就是了,还是我们好啊!
     
    老大,那片文章的第三部分,何时才能出来?热切期待中……
    Sept. 28
    方枪枪wrote:
    对于1),是不是说,如果没有privae symbol,我们还是瞎忙乎?
    Sept. 28

    Trackbacks

    The trackback URL for this entry is:
    http://eparg.spaces.live.com/blog/cns!59BFC22C0E7E1A76!1634.trak
    Weblogs that reference this entry
    • None