ok now i got it, xiaodan. thanks.
tray
Trayambaka Nath Karra <> tkarra@ces.clemson.edu> > wrote:
hello,
thank you so much xiaodan, it is working. but my question is why
cant
the priority of the calling process and the pulse be the same??? why
is
it prohibited in the QNX neutrino architecture.
Sorry, I don’t understand your question.
You want the priority of the pulse be the same as the calling process,
right? Use SIGEV_PULSE_PRIO_INHERIT means that.
NULL (or 0) is not a valid priority, that’s why EINVAL.
If you look at MsgSendPulse() document, it tells you how to get min/max
possiable priority.
-xtang
thanks,
Tray.
“Xiaodan Tang” <> xtang@qnx.com> > wrote in message
news:ajrrn4$at8$> 1@nntp.qnx.com> …
Trayambaka Nath Karra <> tkarra@ces.clemson.edu> > wrote:
hello,
i modified the program and checked out the errno and it is
22-----which
means invalid argument. well, i wanted the priority to be that of the
calling process and so specified it as NULL. thats what is causing
the
problem. so i got the priority of the calling process using
getpriority()
and passed getpriority(PRIO_PROCESS, 0) + 1 as the priority argument
for
MsgSendPulse(…).
Don’t use NULL, use “SIGEV_PULSE_PRIO_INHERIT” (which is defined in
sys/siginfo.h)
-xtang
My program is now working but still i dont understand why cant i send
a
pulse at the priority of the calling process??? Any answers to
my
query
will be greatly appreciated. Anyways, I am sending the program which
is
working properly.
Thanks,
Tray.
#include <stdio.h
#include <stdlib.h
#include <sys/neutrino.h
#include <unistd.h
#include <sys/iomsg.h
#include <errno.h
#include <sys/resource.h
int main()
{
int receiveId, channelId, connectionId, priority;
struct _pulse pulse;
if( (channelId = ChannelCreate(_NTO_CHF_UNBLOCK) ) == -1)
printf(“Error creating a channel \n”);
else
printf(“The channel id is %d\n”, channelId);
if( (connectionId = ConnectAttach( 0, 0, channelId,
_NTO_SIDE_CHANNEL,
0))
== -1)
printf(“error connecting to the channel %d\n”, channelId);
else
printf(“The connection Id is %d\n”, connectionId);
errno = 0;
priority = getpriority( PRIO_PROCESS, 0);
printf(“Priority is %d and errno is %d\n”, priority, errno);
if( MsgSendPulse(connectionId, priority + 1, _PULSE_CODE_MINAVAIL +
5,
32)
!= -1)
printf(“Pulse with code %d and value %d has been sent. \n”,
_PULSE_CODE_MINAVAIL + 5, 32);
else
{
switch (errno)
{
case EAGAIN:
printf(“Kernel insufficient resources.\n”);
break;
case EBADF:
printf(“Invalid connection Id.\n”);
break;
case EFAULT:
printf(“Fault on accessing the buffers.\n”);
break;
case EPERM:
printf(“Permissions invalid.\n”);
break;
case ESRVRFAULT:
printf(“Fault in the servers address space.\n”);
break;
default:
printf(“Unknown error - error number %d\n”, errno);
}
}
if( (MsgReceivePulse(channelId, &pulse, sizeof(pulse), NULL)) != -1)
printf(“Received a pulse with code %d and value %d \n”, pulse.code,
pulse.value);
else
printf(“Error receiving a pulse.\n”);
return 0;
}
“Trayambaka Nath Karra” <> tkarra@ces.clemson.edu> > wrote in message
news:ajrh2i$ctu$> 1@inn.qnx.com> …
Hello,
I am porting a driver from QNX4.25 to QNXRTP and I have to
replace
the
proxies with pulses. So I am trying to get myself familiarised with
the
pulses stuff. I wrote a small program, as shown below and it says
“Unknown
error”. Can anybody please tell me why??.
Thanks,
Tray.
#include <stdio.h
#include <stdlib.h
#include <sys/neutrino.h
#include <unistd.h
#include <sys/iomsg.h
#include <errno.h
int main()
{
int receiveId, channelId, connectionId;
if( (channelId = ChannelCreate(_NTO_CHF_UNBLOCK) ) == -1)
printf(“Error creating a channel \n”);
else
printf(“The channel id is %d\n”, channelId);
if( (connectionId = ConnectAttach( 0, 0, channelId,
_NTO_SIDE_CHANNEL,
0))
== -1)
printf(“error connecting to the channel %d\n”, channelId);
else
printf(“The connection Id is %d\n”, connectionId);
if( MsgSendPulse(connectionId, NULL, _PULSE_CODE_MINAVAIL + 5, 32)
!= -1)
printf(“Pulse with code %d and value %d has been sent. \n”,
_PULSE_CODE_MINAVAIL + 5, 32);
else
{
switch (errno)
{
case EAGAIN:
printf(“Kernel insufficient resources.\n”);
break;
case EBADF:
printf(“Invalid connection Id.\n”);
break;
case EFAULT:
printf(“Fault on accessing the buffers.\n”);
break;
case EPERM:
printf(“Permissions invalid.\n”);
break;
case ESRVRFAULT:
printf(“Fault in the servers address space.\n”);
break;
default:
printf(“Unknown error\n”);
}
}
return 0;
}
\