找回密码
 用户注册

QQ登录

只需一步,快速开始

查看: 3114|回复: 2

suspend不能 ?

[复制链接]
发表于 2007-12-19 21:49:33 | 显示全部楼层 |阅读模式
Ubuntu 6.06 + ACE 5.5 + gcc 4.0.2线程模型posix

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

code:
  1. #include "ace/Log_Msg.h"
  2. #include "ace/Task_T.h"
  3. class Messager : public ACE_Task<ACE_MT_SYNCH>
  4. {
  5. public:
  6.         Messager(){}
  7.         virtual int svc(void)
  8.         {
  9.                 while(1){
  10.                         suspend();
  11.                         ACE_DEBUG((LM_INFO, "in svc()\n"));
  12.                         ACE_OS::sleep(3);
  13.                 }
  14.                 return 0;
  15.         }
  16. };
  17. int main(int argc, ACE_TCHAR* argv[])
  18. {
  19.         Messager mm;
  20.         mm.activate(THR_NEW_LWP|THR_SUSPENDED|THR_JOINABLE); //SUSPENDED seems not take effect, maybe implement it myself with cond?
  21.         mm.suspend();
  22.         ACE_DEBUG((LM_DEBUG, "suspend it\n"));
  23.         while(1);
  24.         mm.wait();
  25.         return 0;
  26. }
复制代码
 楼主| 发表于 2007-12-19 21:49:41 | 显示全部楼层
can you try to get  ACE_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.
 楼主| 发表于 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?
您需要登录后才可以回帖 登录 | 用户注册

本版积分规则

Archiver|手机版|小黑屋|ACE Developer ( 京ICP备06055248号 )

GMT+8, 2024-5-20 10:20 , Processed in 0.361017 second(s), 6 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表