• <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)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            日本亚洲色大成网站WWW久久 | 久久人人爽人人爽人人片AV东京热| 国产精品久久久久9999| 97久久精品人妻人人搡人人玩| 精品久久久久久国产牛牛app| 久久青青色综合| 99久久人妻无码精品系列蜜桃 | 久久ZYZ资源站无码中文动漫| 成人免费网站久久久| 精品久久久久久国产三级| 伊人色综合久久天天人手人婷| 日本免费一区二区久久人人澡 | 久久亚洲sm情趣捆绑调教| 精品久久人妻av中文字幕| 久久久久久一区国产精品| 国产成人无码久久久精品一| 久久综合久久性久99毛片| 97久久久精品综合88久久| 中文国产成人精品久久不卡 | 91久久九九无码成人网站| 人人妻久久人人澡人人爽人人精品| 久久精品国内一区二区三区| 精品久久久久久中文字幕大豆网| 久久播电影网| 国产福利电影一区二区三区久久久久成人精品综合 | 国产精品美女久久久久av爽| 亚洲精品无码久久一线| 中文字幕精品无码久久久久久3D日动漫 | 久久久精品日本一区二区三区 | 久久精品免费一区二区| 欧美日韩中文字幕久久久不卡| 精品久久久久中文字幕一区| 久久国产精品一区二区| 国产精品久久久久无码av| 国产精品久久久久AV福利动漫| 久久亚洲精品成人AV| 精品熟女少妇a∨免费久久| 国产一区二区三区久久| 99久久成人18免费网站| 国产999精品久久久久久| 精品久久久久久无码免费|