GZGQ.COM
welcome to my space
X
Search:  
 HOME   thread hang up ?
thread hang up ?
Published by: jane 2009-01-08
Welcome to:gzgq.com

  • In my multi-thread application, on one node, I used one thread (send thread)to send my defined heart-beat packets via tcp to the other node.The interval is 3 seconds. At the other node, there is a thread(received thread) to received the Heart-beat, sometimes the received thread can not received the packets, I check the send thread, it really does not send, becase once the packets sendout, there incease the packet counter, when the above case happened, the packet counter does not changed. In the send thread, I used pthread_yield() call before delay 3''(pthread_delay_np), Is it possible that the pthread_yield caused thread give up CPU and can not been scheduled in time? The send thread structure looks the following:
    a single thread - unique modern music, igil, rock, electronica ::
    unique modern music, igil, hang-drum didgeridoo, electronica, rock, electronica, John Pascuzzi, played on uncommon instruments in unconventional ways.
    http://asinglethread.com
    HOME

    void send_thread(void)
    {
    ...
    while (1)
    {
    ...
    my_database_access();
    ..
    ret=send(fd,buffer,len);
    ..
    pthread_yield();
    pthread_delay_np(&interval);
    }
    }

    I want to comment out the pthread_yield() to fix the problem, useful? Thanks.Oh, by the way, the application running on the HP True64 UNIX (Alpha server).


  • Um... First things first...

    When you call pthread_yield() you are telling the system that it is OK to switch context and allow another thread ( or process ) gain control of the CPU... the call is typically used in heavy CPU bound threaded code to help prevent starvation of other threads / processes on the system...
    OSNews > Thread > Hang on by kaiwai::
    OSNews.com informs you about the latest news on a vast range of operating systems, from the well-known mainstream OSes, down to small embedded (but also very
    http://www.osnews.com/thread?303246
    HOME
    Presenta Bulletin Board - Redial if disconnected option turns off ::
    The redial, hang-up and shutdown when done functions doesnt save their state. save the state of the redial and hang-up functions in the next versions of iGetter.
    http://www.igetter.net/forums/showthread.php3?threadid=940
    HOME

    There is no guarantee with a pthread_yield() that the thread will give up the CPU... AND there is no guarantee that, if it does give up the CPU, how long an interval of time will pass before it regains it - other than that specified by the current system ( or if present - second level ) scheduler...

    As for the pthread_delay_np()... that np means non-portable... if you want to write portable code and emulate it... create a mutex... create a thread... have the thread lock the mutex and return / exit without unlocking the mutex... then create your thread(s) you want to delay and do a pthread_mutex_timedlock( abs delay time ) call against it...

    One last comment on the pthread_yield call... if you do have code where it would be useful... pthread_yield is superceded by the sched_yield function in the current specs...


    Michael


  • If you want any timing guarantuees whatsoever, then don't use any form of yield.


  • my_database_access(); can probably take some time as well. Not sure what the yield is supposed to do, you're giving the CPU free anyway when doing the delay. Just measure the exact delay you need to sleep just before doing the pthread_delay_np(), instead of assuming everything before it takes no time.


  • I think my_database_access() call will not take enough time at least in the thread, it just only gets the matched record and updates its one attribute value in our realtime database, then the database is implemented by shared memory.
    What I want is to make sure the thread can do the above operation and send the tcp packet after each time of 3 seconds, no matter how long the above operation will take.
    Yes, the same function of pthread_yield has been replaced by the sched_yield() on some current system,but in our system, at least this call is still been supported.
    why the pthread_yield is commented out is there is no dead loop to cause the tcp packet not to send out except the CPU scheduler?!





  • Traditional University or MLM University? You Choose
    15 Questions to Ask Your Software Vendor

    You are looking at:gzgq.com's thread hang up ?, click gzgq.com to home
  • interesting nyc hkg fares
  • warning about eligible mileage accumulation on domestic sas trips
  • private jet getting more in reach
  • toronto star last minute travel yields big savings via internet
  • summer seat sale
  • friday the 13th nightmare at yyz
  • do websaver fares earn aeroplan miles
  • multiple change fees
  • best way to get to vegas
  • ac in talks with its pilots over skyservice discount carrier
  • canada dry aeroplan mile promotion
  • ac forum the question were
  • air canada s regional airlines increase frequency between portland me montreal pq
  • summary of problems with website pto
  •  
  • yxx yyc trip report both the good and odd
  • the front cabin just isn t what it used to be
  • websaver booking problems
  • aeroplan s starnet up and running changes to aeroplan
  • prestige and award tickets
  • new ac mileage partner
  • new look twa aircraft visiting yvr
  • occupation
  • why is itn com always so stupid
  • help with yto lon yto run
  • ac drops plans to fly to india
  • negativity
  • need help for ua flights
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 gzgq.com        Site made:CFZ