• <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 閱讀(2101) 評論(0)  編輯 收藏 引用 所屬分類: C++并發和并行 concurrency & parallelism

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            導航

            統計

            常用鏈接

            留言簿(1)

            隨筆分類

            隨筆檔案

            搜索

            最新評論

            閱讀排行榜

            評論排行榜

            色诱久久久久综合网ywww| 久久亚洲国产精品123区| 无码人妻久久一区二区三区免费| 伊人久久久AV老熟妇色| av午夜福利一片免费看久久| 久久婷婷五月综合97色直播| 亚洲中文久久精品无码| 久久久久久国产精品无码下载 | 国产韩国精品一区二区三区久久| 91精品国产91久久久久久青草| 亚洲欧洲中文日韩久久AV乱码| 亚洲精品国产字幕久久不卡| 国产精品成人99久久久久 | 国内精品伊人久久久久网站| 无码人妻久久久一区二区三区| 国产精品免费久久久久电影网| 亚洲综合日韩久久成人AV| 久久中文字幕视频、最近更新| 久久婷婷五月综合97色一本一本| 久久国产热这里只有精品| 久久99热只有频精品8| 亚洲精品无码久久久| 日本三级久久网| 国产欧美久久久精品| 久久久无码精品亚洲日韩蜜臀浪潮| 无码精品久久一区二区三区| 亚洲综合婷婷久久| 精品久久久久久成人AV| 无码国内精品久久人妻蜜桃| 久久人人爽人人精品视频| 国产午夜精品久久久久九九| 久久96国产精品久久久| 97久久综合精品久久久综合| 久久久久久毛片免费播放| 久久久久亚洲AV无码永不| 亚洲va久久久噜噜噜久久狠狠 | 精品999久久久久久中文字幕 | 99久久99久久精品国产片果冻| 国内精品久久久人妻中文字幕| 日日噜噜夜夜狠狠久久丁香五月| 亚洲国产另类久久久精品 |