欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
epoll_wait是線(xiàn)程退出點(diǎn)嗎? - General - 豆花魚(yú)片加工室
epoll_wait是線(xiàn)程退出點(diǎn)嗎?
在Linux上,epoll_wait是否cancellation point,取決于glibc的版本.
好像在glibc-2.4以上版本中才支持.

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


測試代碼如下:

/*
  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;
}

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
【討論】malloc的可重入性和線(xiàn)程安全性
C++多線(xiàn)程入門(mén)(一)
自己寫(xiě)的C語(yǔ)言線(xiàn)程同步的一個(gè)測試例子
淺析pthread_cond_wait
[pthread] 同步機制(3)
多線(xiàn)程學(xué)習1
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久