VxWorks系统中的signal使用?

panyf_2k 2002-01-25 07:14:27
我有如下程序:
#include <vxWorks.h>
#include <sigLib.h>
#include <taskLib.h>
#include <stdio.h>

void catchSIGINT(int);
void sigCatcher(void);

#define NO_OPTIONS 0
#define ITER1 100
#define LONG_TIME 1000000
#define HIGHPRIORITY 100
#define LOWPRIORITY 101
int ownId;


void sigGenerator(void)
{
int i,j,taskId;
STATUS taskAlive;

if((taskId=taskSpawn("signal",100,0x100,20000,(FUNCPTR)
sigCatcher,0,0,0,0,0,0,0,0,0,0))==ERROR)
printf("taskSpawn sigCatcher failed\n");

ownId=taskIdSelf();

taskDelay(30);

for(i=0;i<ITER1;i++)
{
if((taskAlive=taskIdVerify(taskId))==OK)
{
printf("+++++++++++++++++++++++SIGINT signal
generated\n");

kill(taskId,SIGINT);
taskPrioritySet(ownId,LOWPRIORITY);
}
else
break;
}
printf("\n******************sigGeneratro
Exited***************\n");
}

void sigCatcher(void)
{
struct sigaction newAction;
int i,j;

newAction.sa_handler=catchSIGINT;
sigemptyset(&newAction.sa_mask);
newAction.sa_flags=NO_OPTIONS;

if(sigaction(SIGINT,&newAction,NULL)==-1)
printf("Could not install signal handler\n");

for(i=0;i<ITER1;i++)
{
for(j=0;j<LONG_TIME;j++);
printf("Normal processing in sigCatcher\n");
}
printf("\n+++++++++++++++++++++++++sigCatcher
Exited++++++++++++++++++\n");
}

void catchSIGINT(int signal)
{
printf("-----------------SIGINT signal caught\n");
taskPrioritySet(ownId,HIGHPRIORITY);
}
请问一个问题:
怎么在运行结果中没有"-------------------SIGINT signal caught"
也就是void catchSIGINT()函数好像没有调用,是这样吗?
望请高手指点!谢谢!
...全文
343 10 打赏 收藏 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
panyf_2k 2002-03-01
  • 打赏
  • 举报
回复
难道有关信号和中断的例子就只能到目标机上进行运行?
panyf_2k 2002-03-01
  • 打赏
  • 举报
回复
我只是在单机上模拟.
我所提到的posix和bsd有关系吗?
wenyong 2002-03-01
  • 打赏
  • 举报
回复
你是在目标机上运行吗?还是在模拟器上?
我在目标机上运行时可以打出结果。
panyf_2k 2002-02-26
  • 打赏
  • 举报
回复
wenyong在吗?
帮我看一下!
panyf_2k 2002-02-21
  • 打赏
  • 举报
回复
我按照你所述运行程序,还是没有打印---------SIGNT signal caught
我看到signal有POSIX和BSD环境之分.
我的开发环境是基于win2000下的vxworks开发
不知有这方面的原因?
wenyong 2002-02-08
  • 打赏
  • 举报
回复
#include <vxWorks.h>
#include <sigLib.h>
#include <taskLib.h>
#include <stdio.h>

void catchSIGINT(int);
void sigCatcher(void);

#define NO_OPTIONS 0
#define ITER1 100
#define LONG_TIME 1000000
#define HIGHPRIORITY 100
#define LOWPRIORITY 101
int ownId;


void sigGenerator(void)
{
int i,j,taskId;
STATUS taskAlive;

printf("\n******************sigGenerator Started***************\n");

if( sigInit() == ERROR)
{
printf("signal init error\r\n");
}
if((taskId=taskSpawn("signal",100,0x100,20000,(FUNCPTR)
sigCatcher,0,0,0,0,0,0,0,0,0,0))==ERROR)
printf("taskSpawn sigCatcher failed\n");

ownId=taskIdSelf();

taskDelay(30);

for(i=0;i<ITER1;i++)
{
if((taskAlive=taskIdVerify(taskId))==OK)
{
printf("+++++++++++++++++++++++SIGINT signal generated\n");

kill(taskId,SIGINT);
taskPrioritySet(ownId,LOWPRIORITY);
}
else
break;
}
printf("\n******************sigGenerator Exited***************\n");
}

void sigCatcher(void)
{
struct sigaction newAction,oldAction;
int i,j;
STATUS saStatus;

printf("\n+++++++++++++++++++++++++sigCatcher Started++++++++++++++++++\n");

newAction.sa_handler=catchSIGINT;
sigemptyset(&newAction.sa_mask);
newAction.sa_flags=NO_OPTIONS;

if((saStatus = sigaction(SIGINT,&newAction,&oldAction))== ERROR)
{
printf("Could not install signal handler\n");
return ;
}
else
printf("SIGINT signal installed successfully!\r\n");

pause();

if((saStatus = sigaction(SIGINT,&oldAction,NULL))==ERROR)
printf("Count old uninstall signal handler\n");
else
printf("SIGINT signal uninstalled successfully!\r\n");

printf("\n+++++++++++++++++++++++++sigCatcher Exited++++++++++++++++++\n");
}

void catchSIGINT(int signal)
{
printf("-----------------SIGINT signal caught\n");
taskPrioritySet(ownId,HIGHPRIORITY);
}
wenyong 2002-02-07
  • 打赏
  • 举报
回复
忘了调用sigInit函数初始化VxWorks的信号机制,我已经试过了,SIGINT signal caught 打出来了
wenyong 2002-02-07
  • 打赏
  • 举报
回复
我来研究一下,等等我
turbopeng 2002-01-29
  • 打赏
  • 举报
回复
`up
panyf_2k 2002-01-26
  • 打赏
  • 举报
回复
??
内容概要:本文围绕内置式永磁同步电机(IPMSM)的宽速域控制问题,提出了一种最大转矩电流比(MTPA)与基于解析法的弱磁控制协同策略,旨在实现电机在全速域范围内的高效、稳定运行。研究基于电压饱和判据,设计了精确的分区切换机制,确保在不同转速区间内MTPA与弱磁控制策略的无缝衔接与平滑过渡。通过Simulink搭建了完整的电机控制系统模型,对所提出的协同控制策略进行了详细的仿真验证,重点分析了其在动态加速、减速及负载突变等工况下的宽速域动态特性,证明了该方法在提升系统响应速度、抑制转矩脉动和维持电压稳定方面的优越性能。; 适合人群:从事电机控制、电力电子、新能源汽车或自动化领域的研究生、科研人员及工程技术人员。; 使用场景及目标:① 掌握永磁同步电机在全速域范围内的先进控制策略;② 学习如何设计基于物理约束(如电压饱和)的多模式控制切换逻辑;③ 利用Simulink进行电机控制系统的建模、仿真与性能验证; 其他说明:该资源不仅提供了完整的理论分析和控制框图,还包含了可直接运行的Simulink仿真模型,便于读者复现结果、修改参数并进行二次开发,是深入理解电机高性能控制算法的理想实践材料。

19,524

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧