• <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>
            隨筆 - 42  文章 - 3  trackbacks - 0
            <2009年7月>
            2829301234
            567891011
            12131415161718
            19202122232425
            2627282930311
            2345678

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            網(wǎng)頁收藏

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            =============================================================

            int pthread_create(
                           pthread_t *tid,
                           const pthread_attr_t *attr,
                           void*(*start_routine)(void*),
                           void *arg
                           );
            //參數(shù)tid 用于返回新創(chuàng)建線程的線程號(hào);
            //start_routine 是線程函數(shù)指針,線程從這個(gè)函數(shù)開始獨(dú)立地運(yùn)行;
            //arg 是傳遞給線程函數(shù)的參數(shù)。由于start_routine 是一個(gè)指向參數(shù)類型為void*,返回值為void*的指針,所以如果需要傳遞或返回多個(gè)參數(shù)時(shí),可以使用強(qiáng)制類型轉(zhuǎn)化。

            =============================================================

            void pthread_exit(
                         void* value_ptr
                         );
            // 參數(shù)value_ptr 是一個(gè)指向返回狀態(tài)值的指針。

            =============================================================

            int pthread_join(
                         pthread_t tid ,
                         void **status
                         );
            // 參數(shù)tid 是希望等待的線程的線程號(hào),status 是指向線程返回值的指針,線程的返回值就是pthread_exit 中的value_ptr 參數(shù),或者是return語句中的返回值。該函數(shù)可用于線程間的同步。

            =============================================================

            int pthread_mutex_init(
                               pthread_mutex_t *mutex,
                               const pthread_mutex_attr_t* attr
                               );
            //該函數(shù)初始化一個(gè)互斥體變量,如果參數(shù)attr 為NULL,則互斥
            //體變量mutex 使用默認(rèn)的屬性。

            =============================================================

            int pthread_mutex_lock(
                               pthread_mutex_t *mutex
                               );
            // 該函數(shù)用來鎖住互斥體變量。如果參數(shù)mutex 所指的互斥體已經(jīng)
            //被鎖住了,那么發(fā)出調(diào)用的線程將被阻塞直到其他線程對(duì)mutex 解鎖。

            =============================================================

            int pthread_mutex_trylock(
                                  pthread_t *mutex
                                  );
            //該函數(shù)用來鎖住mutex 所指定的互斥體,但不阻塞。如果該互斥
            //體已經(jīng)被上鎖,該調(diào)用不會(huì)阻塞等待,而會(huì)返回一個(gè)錯(cuò)誤代碼。

            =============================================================

            int pthread_mutex_unlock(
                                 pthread_mutex_t *mutex
                                 );
            //該函數(shù)用來對(duì)一個(gè)互斥體解鎖。如果當(dāng)前線程擁有參數(shù)mutex 所
            //指定的互斥體,該調(diào)用將該互斥體解鎖。

            =============================================================

            int pthread_mutex_destroy (
                                   pthread_mutex_t *mutex
                                   );
            //該函數(shù)用來釋放分配給參數(shù)mutex 的資源。調(diào)用成功時(shí)返回值為
            //0, 否則返回一個(gè)非0 的錯(cuò)誤代碼。

            =============================================================

            int pthread_cond_init(
                              pthread_cond_t *cond,
                              const pthread_cond_attr_t*attr
                              );
            //該函數(shù)按參數(shù)attr指定的屬性創(chuàng)建一個(gè)條件變量。調(diào)用成功返回,
            //并將條件變量ID 賦值給參數(shù)cond,否則返回錯(cuò)誤代碼。

            =============================================================

            int pthread_cond_wait (
                               pthread_cond_t *cond ,
                               pthread_mutex_t*mutex
                               );
            // 該函數(shù)調(diào)用為參數(shù)mutex 指定的互斥體解鎖,等待一個(gè)事件(由
            //參數(shù)cond 指定的條件變量)發(fā)生。調(diào)用該函數(shù)的線程被阻塞直到有其他
            //線程調(diào)用pthread_cond_signal 或pthread_cond_broadcast 函數(shù)置相應(yīng)的條
            //件變量,而且獲得mutex 互斥體時(shí)才解除阻塞。

            =============================================================

            int pthread_cond_timewait(
                                  pthread_cond_t *cond ,
                                  pthread_mutex_t*mutex ,
                                  const struct timespec *abstime
                                  );
            // 該函數(shù)與pthread_cond_wait 不同的是當(dāng)系統(tǒng)時(shí)間到達(dá)abstime 參數(shù)指定的時(shí)間時(shí),被阻塞線程也可以被喚起繼續(xù)執(zhí)行。

            =============================================================

            int pthread_cond_broadcast(
                                   pthread_cond_t *cond
                                   );
            // 該函數(shù)用來對(duì)所有等待參數(shù)cond所指定的條件變量的線程解除阻塞,調(diào)用成功返回0,否則返回錯(cuò)誤代碼。

            =============================================================

            int pthread_cond_signal(
                                pthread_cond_t *cond
                                );
            // 該函數(shù)的作用是解除一個(gè)等待參數(shù)cond所指定的條件變量的線程的阻塞狀態(tài)。當(dāng)有多個(gè)線程掛起等待該條件變量,也只喚醒一個(gè)線程。

            =============================================================

            int pthread_cond_destroy(
                                 pthread_cond_t *cond
                                 );

            // 該函數(shù)的作用是釋放一個(gè)條件變量。釋放為條件變量cond 所分配的資源。調(diào)用成功返回值為0,否則返回錯(cuò)誤代碼。

            =============================================================

            int pthread_key_create(
                               pthread_key_t key ,
                               void(*destructor(void*))
                               );

            // 該函數(shù)創(chuàng)建一個(gè)鍵值,該鍵值映射到一個(gè)專有數(shù)據(jù)結(jié)構(gòu)體上。如果第二個(gè)參數(shù)不是NULL,這個(gè)鍵值被刪除時(shí)將調(diào)用這個(gè)函數(shù)指針來釋放數(shù)據(jù)空間。

            =============================================================

            int pthread_key_delete(
                               pthread_key_t *key
                               );
            // 該函數(shù)用于刪除一個(gè)由pthread_key_create 函數(shù)調(diào)用創(chuàng)建的TSD鍵。調(diào)用成功返回值為0,否則返回錯(cuò)誤代碼。

            =============================================================

            int pthread_setspecific(
                                pthread_key_t key ,
                                const void(value)
                                );
            // 該函數(shù)設(shè)置一個(gè)線程專有數(shù)據(jù)的值,賦給由pthread_key_create 創(chuàng)建的TSD 鍵,調(diào)用成功返回值為0,否則返回錯(cuò)誤代碼。

            =============================================================

            void *pthread_getspecific(
                                pthread_key_t *key
                                );

            // 該函數(shù)獲得綁定到指定TSD 鍵上的值。調(diào)用成功,返回給定參數(shù)key 所對(duì)應(yīng)的數(shù)據(jù)。如果沒有數(shù)據(jù)連接到該TSD 鍵,則返回NULL。

            =============================================================

            int pthread_once(
                         pthread_once_t* once_control,
                         void(*init_routine)(void)
                         );
            //該函數(shù)的作用是確保init_routine 指向的函數(shù),在調(diào)用pthread_once的線程中只被運(yùn)行一次。once_control 指向一個(gè)靜態(tài)或全局的變量。

            =============================================================

            posted on 2011-12-05 07:45 鷹擊長(zhǎng)空 閱讀(260) 評(píng)論(0)  編輯 收藏 引用

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


            久久精品国产精品亚洲艾草网美妙 | 久久99精品久久久久久噜噜| 亚洲国产成人久久精品影视| 色偷偷888欧美精品久久久| 精品熟女少妇aⅴ免费久久| 久久久久久久久波多野高潮| 日产精品久久久一区二区| a级毛片无码兔费真人久久| 无码国内精品久久综合88| 99久久人妻无码精品系列| 欧美久久一区二区三区| 国产精品久久久久久搜索| 久久亚洲国产精品成人AV秋霞| 国产V亚洲V天堂无码久久久| 伊人久久大香线蕉综合5g| 国产999精品久久久久久| 精品久久亚洲中文无码| 久久久精品国产亚洲成人满18免费网站| 久久狠狠爱亚洲综合影院| 久久亚洲AV永久无码精品| 久久久久四虎国产精品| 久久精品国产亚洲精品2020| 亚洲日韩欧美一区久久久久我| 国产精品丝袜久久久久久不卡| 久久精品国产欧美日韩99热| 久久婷婷五月综合色奶水99啪| 久久精品国产精品亚洲| 久久综合久久性久99毛片| yellow中文字幕久久网| 久久亚洲国产精品五月天婷| 狠狠色丁香婷婷久久综合不卡 | 欧美久久综合九色综合| 国产精品一区二区久久精品| 性欧美丰满熟妇XXXX性久久久| 久久夜色精品国产噜噜亚洲a| 香港aa三级久久三级老师2021国产三级精品三级在 | 麻豆精品久久久久久久99蜜桃| 欧美久久久久久午夜精品| 亚洲精品乱码久久久久久中文字幕| 亚洲精品第一综合99久久 | 久久亚洲精品人成综合网|