Hi Community!!!
How is it possible to change the source code, that two or more pulses can be send.
Like in QNX4 with “trigger (proxy)”
Thank You !!!
---------------------------HEADER FILE---------------------------------
struct my_msg
{
short type;
char string[200]; /Message/
struct sigevent event;
};
#define MY_PULSE_CODE _PULSE_CODE_MINAVAIL+5
#define MSG_GIVE_PULSE _IO_MAX+4
/find server/
#define ATTACH_POINT “a”
------------------------SOURCE-----------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/neutrino.h>
#include <sys/iomsg.h>
#include <sys/dispatch.h>
#include “my_hdr.h”
int main( int argc, char **argv)
{
struct my_msg msg;
struct _pulse pulse;
int rcvid,chid, coid, srv_coid;
name_attach_t *attach;
pid_t npid;
npid=fork();
if(npid){ // SERVER
/* attach the name the client will use to find us */
/* our channel will be in the attach structure */
if ( (attach = name_attach( NULL, ATTACH_POINT, 0 )) == NULL)
{
printf("SERVER: failed to attach name, errno %d\n", errno );
exit(1);
}
/* wait for the message from the client */
rcvid = MsgReceive(attach->chid, &msg, sizeof( msg ), NULL );
printf("DIE RCVID IST: %d\n",rcvid);
if ( msg.type == MSG_GIVE_PULSE )
{
/* wait until it is time to notify the client */
sleep(2);
/* deliver notification to client that client requested */
MsgDeliverEvent( rcvid, &msg.event );
printf("SERVER: delivered event\n");
printf("SERVER : Der inhalt des PULSES war: %s\n",msg.string);
} else
{
printf(“SERVER: unexpected message \n”);
}
return 0;
}else{ // CLIENT
strcpy(msg.string,"PULSE PULSE PULSE PULSE ");
/* we need a channel to receive the pulse notification on */
chid = ChannelCreate( 0 );
/* and we need a connection to that channel for the pulse to be
delivered on */
/*If flags contains _NTO_COF_CLOEXEC, the connection is closed
when your process calls an exec*() function to start a new process*/
coid = ConnectAttach( 0, 0, chid, _NTO_SIDE_CHANNEL, 0 );
/* fill in the event structure for a pulse (to send a pulse).*/
/*SIGEV_PULSE_INIT( event, coid, priority, code, value )*/
SIGEV_PULSE_INIT( &msg.event, coid, SIGEV_PULSE_PRIO_INHERIT,
MY_PULSE_CODE, 0 );
msg.type = MSG_GIVE_PULSE; /*"my_hdr.h" */
/* find the server */
if ( (srv_coid = name_open( ATTACH_POINT, 0 )) == -1)
{
printf("CLIENT: failed to find server, errno %d\n", errno );
exit(1);
}
/* give the pulse event we initialized above to the server for
later delivery */
MsgSend( srv_coid, &msg, sizeof(msg), NULL, 0 );
/* wait for the pulse from the server */
rcvid = MsgReceivePulse( chid, &pulse, sizeof( pulse ), NULL );
printf("CLIENT: Receive Code %d waiting for %d \n",
pulse.code, MY_PULSE_CODE );
return 0;
}
}