Leonardo Pappagallo wrote: > Hi Jan, > > I have put the line "mlockall(MCL_CURRENT|MCL_FUTURE)" into my code > at line (***1***) and (***2***). > > in both case the result is the same: > there is a initial delay > > code: > > int main(int argc, char *argv[]) > { > (***1***) > RT_TASK *task_rt; //lpx: task real time > > int udpSocket; //lpx: Socket UDP > > int nFamily=AF_INET; //lpx: protocollo di rete: IP > int nType=SOCK_DGRAM; //lpx: protocollo di trasporto: UDP > int nProtocol = 0; //lpx: ??? > > int nAddr=INADDR_ANY; //lpx: Questo indirizzo > int nPort=15000; //lpx: porta > > // indirizzo interno > struct sockaddr_in MyAdrs; //lpx: indirizzo IP > memset( &MyAdrs, 0, sizeof( MyAdrs ) ); //lpx: azzero variabile > // primo Socket > MyAdrs.sin_family = nFamily; //lpx: tipo di indirizzo > MyAdrs.sin_addr.s_addr = htonl( nAddr ); //lpx: indirizzo IP host > MyAdrs.sin_port = htons( nPort ); //lpx: porta su cui collegarsi > > > // indirizzi degli slave a cui mi devo connettere > char slaveAddress[16] = "192.0.0.255"; > int slavePort=6000; > > // l'inirizzo a cui invierò sarà di tipo broadcast > struct sockaddr_in slaveAdrs; //indirizzo del server che si vuole connettere > int len; //dimensione della > struttura masterAdrs > // i valori li otterro dal primo mesaggio che mi giunge > memset(&slaveAdrs, 0, sizeof( slaveAdrs ) ); //lpx: azzero > variabile > // socket verso il primo slave S1 > slaveAdrs.sin_family = nFamily; //lpx: tipo di > indirizzo > slaveAdrs.sin_addr.s_addr = inet_addr(slaveAddress); //lpx: indirizzo IP > host > slaveAdrs.sin_port = htons(slavePort); //lpx: porta su cui collegarsi > > > const int BufferLen=256; //lpx: > lunghezza buffer di ricezione > char Buffer[BufferLen]; // lpx: punta ai dati da trasmettere > char BufferRx[BufferLen]; //lpx: buffer > di ricezione > > for (int j=1; j<BufferLen; j++) > {// il Buffer[0] lo uso per inserire il numero di datagram > Buffer[j]=j; > } > > int flags=0; // lpx: vedi info sendoto() o recvfrom() > int a,i; // a: ritorno errore , i indice > > > int add_rtskbs=100; //numero di buffer in più da allocare per il socket > int new_rtskbs; //contiene la quantità dei nuovi buffer realmente allocata > //nice(-15); > > (***2***) > > // creo i socket > udpSocket = socket_rt( nFamily, nType, nProtocol); > if (udpSocket<0) > { > printf("errore Socket non creato %d!\n",udpSocket); > //devo rimuovere i socket precedentemente creati > close_rt(udpSocket); //chiudo il socket > ..... > > > do you have any ideas? >
Mmh, I'm not sure about the locking behaviour of glibs regarding main's stack. I think to remember scenarios were, even after mlockall, you first have to touch the stack pages, e.g. by creating a large local array (say 8 KBs) and filling it. To exclude a problem with the real-time environment, you could also try the scenario in kernel space. Should be straight forward: just create RT-tasks and put the while loops into them. The next steps could be to put some time stamp acquisition into the code to see if there are delays between specific calls. You may also use rtcap+ethereal on each node so that outgoing and incoming packets are time-stamped and you can see which side is responsible for the delays. Jan
signature.asc
Description: OpenPGP digital signature