Channels

Hi,

Is it a problem to create more than one channel for one thread?
The reason is that I think that it’s sometimes easier to have a channel with its own MsgReceive() in some functions to just receive pulses triggered by timers, for example. Just because local variables without any signification outside the dedicated function have to be global in other hand.

This question because it seems to be a problem in fact!

In case, just do it!

testChannel.c:

#include <stdio.h>
#include <stdlib.h>
#include <sys/neutrino.h>
#include <sys/dispatch.h>

int main(void)
{
name_attach_t *attach;
int chid, rcvid;

attach = name_attach(NULL, “testChannel”, 0);

while (1)
{
rcvid = MsgReceive(attach->chid, NULL, 0, NULL);
chid = ChannelCreate(0);
printf(“chid %d\n”, chid);
ChannelDestroy(chid);

MsgReply(rcvid, 0, NULL, 0);
}
}



clientChannel.c:
#include <stdlib.h>
#include <sys/neutrino.h>


int main(void)
{
int fd;

fd = name_open(“testChannel”, 0);
MsgSend(fd, NULL, 0, NULL, 0);
name_close(fd);
}

…/testChannel &

if you launch clientChannel many times, you will see chid increasing until fatal value!!

Thanks, Alain.