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

            記錄每日點(diǎn)滴,不枉人生一世

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

            公告

            常用鏈接

            留言簿(24)

            我參與的團(tuán)隊(duì)

            最新隨筆

            搜索

            •  

            積分與排名

            • 積分 -
            • 排名 -

            最新隨筆

            最新評論

            閱讀排行榜

            評論排行榜

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

            假如系統(tǒng)epoll_wait不是cancellation point,那么在某線程執(zhí)行epoll_wait時,另一線程通過pthread_cancel發(fā)出cancel信號,那么表現(xiàn)為:
            1. 在epoll_wait返回之前,線程阻塞該信號,并不響應(yīng);
            2. 當(dāng)epoll_wait返回時,線程立即退出(所有資源不會被釋放),在此之前即使通過pthread_cleanup_push注冊了銷毀時的回調(diào)函數(shù)也不會被執(zhí)行;同時,如果有線程阻塞在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 閱讀(997) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            国产精品成人久久久久三级午夜电影 | 亚洲精品乱码久久久久久自慰| 免费精品久久天干天干| 国产成人久久精品激情 | 伊人久久大香线蕉亚洲| 久久se精品一区精品二区国产| 久久人人爽人人爽人人AV东京热 | 天天久久狠狠色综合| 久久Av无码精品人妻系列| 久久久久久久免费视频| 久久久亚洲精品蜜桃臀| 久久精品女人天堂AV麻| 国产精品嫩草影院久久| 亚洲欧洲日产国码无码久久99| 99热精品久久只有精品| 一本色道久久88—综合亚洲精品| 国产精品狼人久久久久影院| 久久人人爽人人爽人人AV东京热| 国产高潮久久免费观看| 1000部精品久久久久久久久| 国产美女久久久| 国产一区二区三精品久久久无广告 | 久久久久亚洲AV无码去区首| 亚洲国产精品无码久久SM| 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 久久www免费人成精品香蕉| 九九久久自然熟的香蕉图片| 久久国产免费直播| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 国产精品9999久久久久| 欧美黑人又粗又大久久久| 国产精品久久久久久久app| 久久人人爽人爽人人爽av| 嫩草影院久久99| 国产成人久久精品二区三区| 香港aa三级久久三级| 色婷婷综合久久久久中文字幕| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久久午夜精品| 久久久久久曰本AV免费免费| 久久精品国产99国产精品导航 |