peakzhang 发表于 2007-12-19 21:49:33

suspend不能 ?

Ubuntu 6.06 + ACE 5.5 + gcc 4.0.2线程模型posix

我从ACE_Task<ACE_MT_SYNCH>派生的类,不知为何不能挂起,跑得贼欢,烦请各位指点 orz

code:

#include "ace/Log_Msg.h"
#include "ace/Task_T.h"

class Messager : public ACE_Task<ACE_MT_SYNCH>
{
public:
      Messager(){}

      virtual int svc(void)
      {
                while(1){
                        suspend();
                        ACE_DEBUG((LM_INFO, "in svc()\n"));
                        ACE_OS::sleep(3);
                }
                return 0;
      }
};


int main(int argc, ACE_TCHAR* argv[])
{
      Messager mm;

      mm.activate(THR_NEW_LWP|THR_SUSPENDED|THR_JOINABLE); //SUSPENDED seems not take effect, maybe implement it myself with cond?
      mm.suspend();
      ACE_DEBUG((LM_DEBUG, "suspend it\n"));

      while(1);
      mm.wait();

      return 0;
}

peakzhang 发表于 2007-12-19 21:49:41

can you try to getACE_OS::last_error();
Not all the platforms support suspend.
Which kernel version you have. Most likely your kernel doesn't support suspend.
BTW, suspend from another thread is not good idea.

peakzhang 发表于 2007-12-19 21:49:47

My kernel is 2.6.17-10 ...
I tried ACE_OS::last_error(), which returned 95.
I used ACE_OS::perror, it said "Operation not supported"

I got it, thanks very much

One more thing, "suspend from another thread is not good idea", do you mean such action may cause fatal error like segment fault , or mean it may suspend that thread in some unexpected place?
页: [1]
查看完整版本: suspend不能 ?