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

            我參與的團隊

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 - 454869
            • 排名 - 48

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

            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 閱讀(992) 評論(0)  編輯 收藏 引用
            69久久精品无码一区二区| 国产色综合久久无码有码| 久久精品国产91久久综合麻豆自制| 精品久久一区二区三区| 久久伊人精品青青草原高清| 久久一区二区免费播放| 午夜精品久久久久久毛片| 久久93精品国产91久久综合| 亚洲精品WWW久久久久久| 久久久久久毛片免费播放| 久久久久人妻一区精品果冻| 亚洲精品乱码久久久久久蜜桃图片 | 性欧美大战久久久久久久久| 亚洲日本va中文字幕久久| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久亚洲精品视频| 97精品依人久久久大香线蕉97| 国产精品无码久久综合网| 欧洲精品久久久av无码电影| 久久婷婷五月综合成人D啪| 国产精品一久久香蕉产线看| 亚洲香蕉网久久综合影视 | 精品久久久久久中文字幕人妻最新 | avtt天堂网久久精品| 亚洲色大成网站www久久九| 日本国产精品久久| 精品久久一区二区| 99re久久精品国产首页2020| 一本色道久久88—综合亚洲精品| 久久久久久国产a免费观看不卡| 国产精品久久久久久吹潮| 久久久精品人妻一区二区三区四 | 精品永久久福利一区二区| 久久午夜无码鲁丝片秋霞| 色狠狠久久综合网| 伊人久久五月天| 中文成人无码精品久久久不卡| 国产精品美女久久久久AV福利| 国产激情久久久久影院老熟女| 久久精品国产精品青草| 91精品国产高清久久久久久91 |