• <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++并發(fā)和并行 concurrency & parallelism

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

            導(dǎo)航

            統(tǒng)計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            av无码久久久久不卡免费网站| 久久人人青草97香蕉| …久久精品99久久香蕉国产| 国产精品久久永久免费| 欧美日韩精品久久久久| 色欲综合久久中文字幕网| 久久久国产精品福利免费| 久久久久99这里有精品10| 国产日产久久高清欧美一区| 久久人妻少妇嫩草AV蜜桃| 久久综合综合久久狠狠狠97色88| 伊人久久大香线蕉综合影院首页| 国产精品国色综合久久| 久久人人青草97香蕉| 久久精品国产亚洲Aⅴ蜜臀色欲| 精品国产青草久久久久福利| 色欲综合久久中文字幕网| 国产精品女同一区二区久久| 久久婷婷五月综合色高清| 怡红院日本一道日本久久 | 久久精品国产亚洲5555| 久久综合九色综合网站 | 久久久久久久综合狠狠综合| 精品久久久久久| 久久精品人成免费| 亚洲精品无码久久一线| 国内精品久久久久影院老司 | 久久久久久精品成人免费图片| 久久久久噜噜噜亚洲熟女综合| 亚洲狠狠久久综合一区77777| 好久久免费视频高清| 热re99久久精品国99热| 一本久久知道综合久久| 久久久久久久91精品免费观看| 三级片免费观看久久| 久久强奷乱码老熟女| 一本色综合网久久| 一本色道久久HEZYO无码| 亚洲狠狠婷婷综合久久蜜芽| 亚洲精品无码专区久久久| 午夜精品久久久久久久久|