亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? thread.c

?? 在Linux/Unix環(huán)境下發(fā)包測試性能的工具
?? C
字號:
/*---------------------------------------------------------------  * Copyright (c) 1999,2000,2001,2002,2003                               * The Board of Trustees of the University of Illinois             * All Rights Reserved.                                            *---------------------------------------------------------------  * Permission is hereby granted, free of charge, to any person     * obtaining a copy of this software (Iperf) and associated        * documentation files (the "Software"), to deal in the Software   * without restriction, including without limitation the           * rights to use, copy, modify, merge, publish, distribute,         * sublicense, and/or sell copies of the Software, and to permit      * persons to whom the Software is furnished to do * so, subject to the following conditions:  * *      * Redistributions of source code must retain the above  * copyright notice, this list of conditions and  * the following disclaimers.  * *      * Redistributions in binary form must reproduce the above  * copyright notice, this list of conditions and the following  * disclaimers in the documentation and/or other materials  * provided with the distribution.  *  *      * Neither the names of the University of Illinois, NCSA,  * nor the names of its contributors may be used to endorse  * or promote products derived from this Software without * specific prior written permission.  *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTIBUTORS OR COPYRIGHT  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  * ________________________________________________________________ * National Laboratory for Applied Network Research  * National Center for Supercomputing Applications  * University of Illinois at Urbana-Champaign  * http://www.ncsa.uiuc.edu * ________________________________________________________________  * * Thread.c * by Kevin Gibbs <kgibbs@nlanr.net> * * Based on: * Thread.cpp * by Mark Gates <mgates@nlanr.net> * ------------------------------------------------------------------- * The thread subsystem is responsible for all thread functions. It * provides a thread implementation agnostic interface to Iperf. If  * threads are not available (HAVE_THREAD is undefined), thread_start * does not start a new thread but just launches the specified object  * in the current thread. Everything that defines a thread of  * execution in Iperf is contained in an thread_Settings structure. To * start a thread simply pass one such structure into thread_start. * ------------------------------------------------------------------- * headers * uses *   <stdlib.h> *   <stdio.h> *   <assert.h> *   <errno.h> * Thread.h may include <pthread.h> * ------------------------------------------------------------------- */#include "headers.h"#include "Thread.h"#include "Locale.h"#include "util.h"#ifdef __cplusplusextern "C" {#endif/* ------------------------------------------------------------------- * define static variables. * ------------------------------------------------------------------- */// number of currently running threadsint thread_sNum = 0;// number of non-terminating running threads (ie listener thread)int nonterminating_num = 0;// condition to protect updating the above and alerting on // changes to aboveCondition thread_sNum_cond;/* ------------------------------------------------------------------- * Initialize the thread subsystems variables and set the concurrency * level in solaris. * ------------------------------------------------------------------- */void thread_init( ) {    Condition_Initialize( &thread_sNum_cond );#if defined( sun )    /* Solaris apparently doesn't default to timeslicing threads,     * as such we force it to play nice. This may not work perfectly     * when _sending_ multiple _UDP_ streams.     */    pthread_setconcurrency (3);#endif}/* ------------------------------------------------------------------- * Destroy the thread subsystems variables. * ------------------------------------------------------------------- */void thread_destroy( ) {    Condition_Destroy( &thread_sNum_cond );}/* ------------------------------------------------------------------- * Start the specified object's thread execution. Increments thread * count, spawns new thread, and stores thread ID. * ------------------------------------------------------------------- */void thread_start( struct thread_Settings* thread ) {    // Make sure this object has not been started already    if ( thread_equalid( thread->mTID, thread_zeroid() ) ) {        // Check if we need to start another thread before this one        if ( thread->runNow != NULL ) {            thread_start( thread->runNow );        }        // increment thread count        Condition_Lock( thread_sNum_cond );        thread_sNum++;        Condition_Unlock( thread_sNum_cond );#if   defined( HAVE_POSIX_THREAD )        // pthreads -- spawn new thread        if ( pthread_create( &thread->mTID, NULL, thread_run_wrapper, thread ) != 0 ) {            WARN( 1, "pthread_create" );            // decrement thread count            Condition_Lock( thread_sNum_cond );            thread_sNum--;            Condition_Unlock( thread_sNum_cond );        }#elif defined( HAVE_WIN32_THREAD )        // Win32 threads -- spawn new thread        // Win32 has a thread handle in addition to the thread ID        thread->mHandle = CreateThread( NULL, 0, thread_run_wrapper, thread, 0, &thread->mTID );        if ( thread->mHandle == NULL ) {            WARN( 1, "CreateThread" );            // decrement thread count            Condition_Lock( thread_sNum_cond );            thread_sNum--;            Condition_Unlock( thread_sNum_cond );        }#else        // single-threaded -- call Run_Wrapper in this thread        thread_run_wrapper( thread );#endif    }} // end thread_start/* ------------------------------------------------------------------- * Stop the specified object's thread execution (if any) immediately. * Decrements thread count and resets the thread ID. * ------------------------------------------------------------------- */void thread_stop( struct thread_Settings* thread ) {#ifdef HAVE_THREAD    // Make sure we have been started    if ( ! thread_equalid( thread->mTID, thread_zeroid() ) ) {        // decrement thread count        Condition_Lock( thread_sNum_cond );        thread_sNum--;        Condition_Signal( &thread_sNum_cond );        Condition_Unlock( thread_sNum_cond );        // use exit()   if called from within this thread        // use cancel() if called from a different thread        if ( thread_equalid( thread_getid(), thread->mTID ) ) {            // Destroy the object            Settings_Destroy( thread );            // Exit#if   defined( HAVE_POSIX_THREAD )            pthread_exit( NULL );#else // Win32            CloseHandle( thread->mHandle );            ExitThread( 0 );#endif        } else {            // Cancel#if   defined( HAVE_POSIX_THREAD )            // Cray J90 doesn't have pthread_cancel; Iperf works okay without#ifdef HAVE_PTHREAD_CANCEL            pthread_cancel( oldTID );#endif#else // Win32            // this is a somewhat dangerous function; it's not            // suggested to Stop() threads a lot.            TerminateThread( thread->mHandle, 0 );#endif            // Destroy the object only after killing the thread            Settings_Destroy( thread );        }    }#endif} // end Stop/* ------------------------------------------------------------------- * This function is the entry point for new threads created in  * thread_start.  * ------------------------------------------------------------------- */#if   defined( HAVE_WIN32_THREAD )DWORD WINAPI#elsevoid*#endifthread_run_wrapper( void* paramPtr ) {    struct thread_Settings* thread = (struct thread_Settings*) paramPtr;    // which type of object are we    switch ( thread->mThreadMode ) {        case kMode_Server:            {                /* Spawn a Server thread with these settings */                server_spawn( thread );            } break;        case kMode_Client:            {                /* Spawn a Client thread with these settings */                client_spawn( thread );            } break;        case kMode_Reporter:            {                /* Spawn a Reporter thread with these settings */                reporter_spawn( thread );            } break;        case kMode_Listener:            {                // Increment the non-terminating thread count                thread_register_nonterm();                /* Spawn a Listener thread with these settings */                listener_spawn( thread );                // Decrement the non-terminating thread count                thread_unregister_nonterm();            } break;        default:            {                FAIL(1, "Unknown Thread Type!\n", thread);            } break;    }#ifdef HAVE_POSIX_THREAD    // detach Thread. If someone already joined it will not do anything    // If noone has then it will free resources upon return from this    // function (Run_Wrapper)    pthread_detach(thread->mTID);#endif    // decrement thread count and send condition signal    Condition_Lock( thread_sNum_cond );    thread_sNum--;    Condition_Signal( &thread_sNum_cond );    Condition_Unlock( thread_sNum_cond );    // Check if we need to start up a thread after executing this one    if ( thread->runNext != NULL ) {        thread_start( thread->runNext );    }    // Destroy this thread object    Settings_Destroy( thread );    return 0;} // end run_wrapper/* ------------------------------------------------------------------- * Wait for all thread object's execution to complete. Depends on the * thread count being accurate and the threads sending a condition * signal when they terminate. * ------------------------------------------------------------------- */void thread_joinall( void ) {    Condition_Lock( thread_sNum_cond );    while ( thread_sNum > 0 ) {        Condition_Wait( &thread_sNum_cond );    }    Condition_Unlock( thread_sNum_cond );} // end Joinall/* ------------------------------------------------------------------- * Compare the thread ID's (inLeft == inRight); return true if they * are equal. On some OS's nthread_t is a struct so == will not work. * TODO use pthread_equal. Any Win32 equivalent?? * ------------------------------------------------------------------- */int thread_equalid( nthread_t inLeft, nthread_t inRight ) {    return(memcmp( &inLeft, &inRight, sizeof(inLeft)) == 0);}/* ------------------------------------------------------------------- * Return a zero'd out thread ID. On some OS's nthread_t is a struct * so == 0 will not work. * [static] * ------------------------------------------------------------------- */nthread_t thread_zeroid( void ) {    nthread_t a;    memset( &a, 0, sizeof(a));    return a;}/* ------------------------------------------------------------------- * set a thread to be ignorable, so joinall won't wait on it * this simply decrements the thread count that joinall uses. * This is utilized by the reporter thread which knows when it * is ok to quit (aka no pending reports). * ------------------------------------------------------------------- */void thread_setignore( ) {    Condition_Lock( thread_sNum_cond );    thread_sNum--;    Condition_Signal( &thread_sNum_cond );    Condition_Unlock( thread_sNum_cond );}/* ------------------------------------------------------------------- * unset a thread from being ignorable, so joinall will wait on it * this simply increments the thread count that joinall uses. * This is utilized by the reporter thread which knows when it * is ok to quit (aka no pending reports). * ------------------------------------------------------------------- */void thread_unsetignore( void ) {    Condition_Lock( thread_sNum_cond );    thread_sNum++;    Condition_Signal( &thread_sNum_cond );    Condition_Unlock( thread_sNum_cond );}/* ------------------------------------------------------------------- * set a thread to be non-terminating, so if you cancel through * Ctrl-C they can be ignored by the joinall. * ------------------------------------------------------------------- */void thread_register_nonterm( void ) {    Condition_Lock( thread_sNum_cond );    nonterminating_num++;     Condition_Unlock( thread_sNum_cond );}/* ------------------------------------------------------------------- * unset a thread from being non-terminating, so if you cancel through * Ctrl-C they can be ignored by the joinall. * ------------------------------------------------------------------- */void thread_unregister_nonterm( void ) {    Condition_Lock( thread_sNum_cond );    if ( nonterminating_num == 0 ) {        // nonterminating has been released with release_nonterm        // Add back to the threads to wait on        thread_sNum++;    } else {        nonterminating_num--;     }    Condition_Unlock( thread_sNum_cond );}/* ------------------------------------------------------------------- * this function releases all non-terminating threads from the list * of active threads, so that when all terminating threads quit * the joinall will complete. This is called on a Ctrl-C input. It is * also used by the -P usage on the server side * ------------------------------------------------------------------- */int thread_release_nonterm( int interrupt ) {    Condition_Lock( thread_sNum_cond );    thread_sNum -= nonterminating_num;    if ( thread_sNum > 1 && nonterminating_num > 0 && interrupt != 0 ) {        fprintf( stderr, wait_server_threads );    }    nonterminating_num = 0;    Condition_Signal( &thread_sNum_cond );    Condition_Unlock( thread_sNum_cond );    return thread_sNum;}/* ------------------------------------------------------------------- * Return the number of threads currently running (doesn't include * active threads that have called setdaemon (aka reporter thread)) * ------------------------------------------------------------------- */int thread_numuserthreads( void ) {    return thread_sNum;}/* * ------------------------------------------------------------------- * Allow another thread to execute. If no other threads are runable this * is not guarenteed to actually rest. * ------------------------------------------------------------------- */void thread_rest ( void ) {#if defined( HAVE_THREAD )#if defined( HAVE_POSIX_THREAD )    // TODO add checks for sched_yield or pthread_yield and call that    // if available    usleep( 0 );#else // Win32    SwitchToThread( );#endif#endif}#ifdef __cplusplus} /* end extern "C" */#endif

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99精品国产99久久久久久白柏| eeuss鲁一区二区三区| 国产欧美日韩在线视频| 不卡av电影在线播放| 日韩综合一区二区| 欧美优质美女网站| 国内精品在线播放| 亚洲一区免费观看| 国产色婷婷亚洲99精品小说| 一本久久a久久精品亚洲| 日韩av一二三| 国产精品福利电影一区二区三区四区| 成人午夜在线免费| 日本人妖一区二区| 亚洲免费观看高清完整 | 91行情网站电视在线观看高清版| 天堂蜜桃91精品| 国产精品麻豆久久久| 欧美一区二区三区免费大片| 色综合天天综合网国产成人综合天| 久久国产夜色精品鲁鲁99| 一区二区三区产品免费精品久久75| 精品国产伦一区二区三区免费| 福利一区二区在线| 亚洲自拍都市欧美小说| 国产午夜精品久久| 日韩三区在线观看| 欧美视频在线一区| 不卡电影一区二区三区| 国产在线视频一区二区三区| 亚洲五码中文字幕| 亚洲日本中文字幕区| 久久先锋资源网| 欧美精品 国产精品| 欧美亚洲一区三区| 91丨九色丨蝌蚪富婆spa| 日韩av中文字幕一区二区三区| 一区二区三区电影在线播| 国产精品乱人伦| 久久亚洲欧美国产精品乐播| 日韩西西人体444www| 在线电影院国产精品| 欧美性色综合网| 91久久精品一区二区| 成人免费视频播放| 高清av一区二区| 岛国一区二区三区| 国产成人在线视频网址| 国产一区二区三区免费看| 一区二区三区精品在线| 亚洲免费av高清| 亚洲精品成人少妇| 亚洲靠逼com| 亚洲欧美国产高清| 亚洲欧洲日韩av| 亚洲欧美另类小说| 亚洲婷婷在线视频| 亚洲三级久久久| 一区二区三区在线视频观看58| 国产日本欧美一区二区| 久久久99免费| 国产精品久久久久久户外露出| 欧美高清在线视频| 中文字幕一区二区三| 亚洲婷婷在线视频| 亚洲一二三四区| 丝袜亚洲另类欧美综合| 免费精品视频在线| 国产精品一线二线三线| 国产精品99久久久久久宅男| 精久久久久久久久久久| 国模一区二区三区白浆| 成人性色生活片免费看爆迷你毛片| 国产不卡在线一区| 99re热这里只有精品视频| jiyouzz国产精品久久| 色婷婷av一区| 欧洲精品一区二区| 日韩视频一区二区在线观看| 2022国产精品视频| 国产精品毛片高清在线完整版 | 国产成人午夜视频| 成人国产精品免费观看动漫| 一本大道久久精品懂色aⅴ | 欧美日韩成人综合在线一区二区| 4438成人网| 久久午夜色播影院免费高清| 国产精品污网站| 亚洲一区二区成人在线观看| 亚洲成a人片在线观看中文| 精品综合免费视频观看| 波多野结衣亚洲一区| 色综合中文综合网| 国产成人在线视频网站| 色综合久久综合网| 欧美一二区视频| 欧美高清在线视频| 日本少妇一区二区| yourporn久久国产精品| 在线播放欧美女士性生活| 久久久久成人黄色影片| 亚洲一区二区不卡免费| 国产99久久久国产精品免费看| 成人av手机在线观看| 在线综合视频播放| 综合欧美亚洲日本| 久久99精品国产| 91国产免费看| 国产亚洲精品久| 香蕉久久夜色精品国产使用方法| 久久精品国产一区二区| 色伊人久久综合中文字幕| 精品国产人成亚洲区| 亚洲美女免费视频| 国产suv精品一区二区883| 在线观看三级视频欧美| 中文字幕不卡三区| 精品一区二区久久久| 欧美色图12p| 国产精品短视频| 久久成人久久鬼色| 欧美日韩国产精品成人| 国产精品久久久久9999吃药| 精品写真视频在线观看| 欧美日韩一区二区三区四区| 亚洲婷婷在线视频| 麻豆精品视频在线| 欧美日韩中字一区| 亚洲欧美日韩中文字幕一区二区三区| 久久成人免费网站| 欧美一区二区三区四区高清 | 国产精品免费视频网站| 久草在线在线精品观看| 欧美男男青年gay1069videost | 一片黄亚洲嫩模| 色综合久久久久综合99| 亚洲乱码国产乱码精品精98午夜 | 午夜a成v人精品| 欧美日韩国产另类一区| 日本特黄久久久高潮| 日韩欧美高清一区| 国产乱人伦偷精品视频免下载 | 丝袜美腿亚洲色图| 91精品国产入口| 韩国中文字幕2020精品| 久久久久99精品国产片| 不卡一区在线观看| 亚洲综合色视频| 欧美肥妇bbw| 激情综合网最新| 久久久精品国产免大香伊| 成人av在线资源网站| 亚洲伦理在线免费看| 欧美精品日韩综合在线| 九九九精品视频| 国产精品麻豆欧美日韩ww| 91视频观看视频| 午夜精品成人在线| 亚洲精品在线观看网站| 成人亚洲一区二区一| 一区二区久久久久| 日韩一级高清毛片| 国产盗摄视频一区二区三区| 亚洲女性喷水在线观看一区| 91精品蜜臀在线一区尤物| 国产精品主播直播| 亚洲精品高清在线观看| 日韩精品一区二区三区老鸭窝| 国产91在线观看丝袜| 亚洲综合激情小说| www激情久久| 欧洲亚洲国产日韩| 国产九九视频一区二区三区| 亚洲人成网站色在线观看| 欧美一区二区三区四区高清 | 粉嫩av一区二区三区粉嫩| 夜夜夜精品看看| 精品国产电影一区二区| 99re这里只有精品首页| 蜜桃一区二区三区四区| 亚洲视频免费在线观看| 欧美成人一区二区三区在线观看| 成人av在线网站| 免费欧美高清视频| 国产精品看片你懂得| 日韩欧美三级在线| 在线免费观看成人短视频| 久久99国产精品久久99| 亚洲精品日韩综合观看成人91| 日韩欧美第一区| 在线观看欧美日本| 高清国产一区二区| 看片的网站亚洲| 一区二区三区欧美日韩| 欧美国产精品一区二区三区| 69堂成人精品免费视频| 色999日韩国产欧美一区二区| 国产伦精品一区二区三区在线观看 | www.成人网.com| 经典一区二区三区|