• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++ library系列 -- static destructors in multiple threads

              In VC++ 8.0, while  code compiled with /clr or /clr:pure, static destructors sometimes would not being properly called before process exites in multiple threads.

              CRT incorrectly set a lock at _global_unlock which resulted in such issue.

              In CLR-mixed mode, during the inialization of static local object, CRT would call _atexit_m(_CPVFV func) in msilexit.cpp to register a special __clrcall callback function which would be called back to destroy such static object when the current AppDomain quited.

              In the multithread environment, _atexit_helper which was invoked by _atexit_m, could register such callbace function successfully because it had been guarded by __global_lock() and __global_unlock(). But in the same environment, the _atexit_m would fail to assign the correct value to __onexitbegin_m and __onexitend_m.

              __onexitbegin_m and __onexitend_m were shared by the different threads; It's the key point of such issue. For example, the following statements,

              __onexitbegin_m = (_CPVFV *)_encode_pointer(onexitbegin_m);
              __onexitend_m = (_CPVFV *)_encode_pointer(onexitend_m);

            should also guarded by __global_lock() and __global_unlock() or other syn primitives.


            __global_lock();
            __onexitbegin_m = (_CPVFV *)_encode_pointer(onexitbegin_m);
            __onexitend_m   = (_CPVFV *)_encode_pointer(onexitend_m);
            __global_unlock();


            extern "C" int __clrcall _atexit_m(_CPVFV func)
            {
             MANAGED_ASSERT(AppDomain::CurrentDomain->IsDefaultAppDomain(), "This fuction must be called in the default domain");

             __global_lock();
             _CPVFV* onexitbegin_m = (_CPVFV*)_decode_pointer(__onexitbegin_m);
             _CPVFV* onexitend_m = (_CPVFV*)_decode_pointer(__onexitend_m);
             __global_unlock();

             int retval = _atexit_helper((_CPVFV)_encode_pointer(func), &__exit_list_size, &onexitend_m, &onexitbegin_m);

             __global_lock();
             __onexitbegin_m = (_CPVFV*)_encode_pointer(onexitbegin_m);
             __onexitend_m  = (_CPVFV*)_encode_pointer(onexitend_m);
             __global_unlock();

             return retval;
            }

            posted on 2011-02-08 20:57 flagman 閱讀(2105) 評論(0)  編輯 收藏 引用 所屬分類: C++并發和并行 concurrency & parallelism

            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            亚洲av日韩精品久久久久久a| 免费观看成人久久网免费观看| 人人狠狠综合久久亚洲高清| 久久久久久av无码免费看大片 | 亚洲成色WWW久久网站| 伊人久久综合成人网| 日本精品久久久中文字幕| 久久亚洲精品无码播放| 少妇内射兰兰久久| 国产精品青草久久久久福利99 | 久久99精品国产99久久| 久久亚洲国产精品五月天婷| 久久青青草原精品国产| 污污内射久久一区二区欧美日韩| 亚洲国产精品无码久久一线| 久久久久久久久久免免费精品| 久久精品人人做人人妻人人玩| 国产亚洲精久久久久久无码AV| 色婷婷久久综合中文久久蜜桃av| 久久av高潮av无码av喷吹| 色妞色综合久久夜夜| 亚洲国产精品无码久久久久久曰 | 色播久久人人爽人人爽人人片aV| 色88久久久久高潮综合影院| 欧美与黑人午夜性猛交久久久 | 国产精品99久久久精品无码| 国产精品成人无码久久久久久 | 久久午夜免费视频| 国产真实乱对白精彩久久| 九九99精品久久久久久| 久久亚洲AV成人出白浆无码国产| 亚洲色欲久久久久综合网| 久久天天躁狠狠躁夜夜2020| 草草久久久无码国产专区| 国产精品无码久久久久| 日韩亚洲欧美久久久www综合网| 99久久精品国产高清一区二区| 精品久久久噜噜噜久久久| 久久99国产综合精品免费| 精品人妻久久久久久888| 久久亚洲精品无码AV红樱桃|