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

            doing5552

            記錄每日點滴,不枉人生一世

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              73 Posts :: 0 Stories :: 94 Comments :: 0 Trackbacks

            公告

            常用鏈接

            留言簿(24)

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 455382
            • 排名 - 49

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            epoll_wait是線程退出點嗎?
            2010年04月02日 星期五 上午 10:46
            在Linux上,epoll_wait是否cancellation point,取決于glibc的版本.
            好像在glibc-2.4以上版本中才支持.

            假如系統epoll_wait不是cancellation point,那么在某線程執行epoll_wait時,另一線程通過pthread_cancel發出cancel信號,那么表現為:
            1. 在epoll_wait返回之前,線程阻塞該信號,并不響應;
            2. 當epoll_wait返回時,線程立即退出(所有資源不會被釋放),在此之前即使通過pthread_cleanup_push注冊了銷毀時的回調函數也不會被執行;同時,如果有線程阻塞在pthread_join等待此線程退出的話,則會返回.


            測試代碼如下:

            /*
            test epoll_wait is a cancellation point.
            glibc-2.4 or later support.

              fedora 5 support.
            */


            #include <sys/epoll.h>
            #include <pthread.h>
            #include <stdio.h>
            #include <unistd.h>

            void * run (int * events) {
            struct epoll_event storage;

            printf("Wait start.\n");
            /* block forever */
            epoll_wait(*events, &storage, 1, -1/*10000*/);

            printf("Wait stop.\n");

            return NULL;
            }

            int main (void) {
            int events;
            pthread_t new_thread;

            events = epoll_create(1);
            pthread_create(&new_thread, NULL, (void * (*) (void *))run, &events);

            /* wait for enter keypress to try pthread cancellation */
            getchar();
            printf("Cleanup start.\n");
            pthread_cancel(new_thread);

            /* let's see if this returns or not */
            pthread_join(new_thread, NULL);

            /* if to here, the epoll_wait is a cancellation point. */
            printf("Cleanup stop.\n");


            close(events);
            return 0;
            }

            posted on 2010-07-18 21:15 doing5552 閱讀(1001) 評論(0)  編輯 收藏 引用
            日本国产精品久久| 亚洲国产成人久久综合一 | 一本色道久久HEZYO无码| 国内精品久久久久影院老司| 久久精品国产亚洲Aⅴ香蕉| 久久中文字幕精品| 99久久99久久精品免费看蜜桃| 久久精品国产亚洲综合色| 合区精品久久久中文字幕一区 | 狠狠人妻久久久久久综合蜜桃| 狠狠久久综合伊人不卡| 久久精品国产清高在天天线| 久久国产精品久久国产精品| 久久久综合香蕉尹人综合网| 久久精品国产亚洲AV忘忧草18| 久久国产色AV免费看| 久久九九兔免费精品6| 久久久精品免费国产四虎| 人人狠狠综合久久亚洲高清| 国产高清美女一级a毛片久久w | 亚洲欧洲久久久精品| 国产69精品久久久久99| 亚洲午夜久久久影院| 久久久久久国产a免费观看黄色大片 | 亚洲精品无码久久久| Xx性欧美肥妇精品久久久久久| 欧美午夜精品久久久久免费视| 一级做a爰片久久毛片看看| 久久99精品久久久久久9蜜桃 | 久久青草国产手机看片福利盒子 | AV无码久久久久不卡蜜桃| 久久久亚洲AV波多野结衣| 婷婷久久综合| 久久伊人五月丁香狠狠色| 久久人人爽人人爽人人片AV高清 | 久久永久免费人妻精品下载| 77777亚洲午夜久久多人| 久久AV高潮AV无码AV| 久久狠狠爱亚洲综合影院| 久久99精品久久久久久动态图| 久久精品中文騷妇女内射|