Dennis Windisch wrote: > I've re-written an existing communication process to use RTnet (a LXRT task > using the RTnet API). A few days ago, when I tested it, it worked fine. > > But now it doesn't work and I've found that the failure is already the > opening of the socket with socket_rt. When I do it before the > rt_make_hard_real_time call, the socket gets opened (positive int return), > after the call the socket returns a negative int (opening failure). > > After a litte recherche, I found that it could give problems opening a > socket in RT context and it is recommended to do it in non-RT context. But > since it succeeded just a couple of days ago, I'm quite curious whats the > actual state of affairs regarding socket_rt and rt_make_hard_real_time is. > > Is there a "trick" to open a socket in RT context? >
Yes. The trick is to fill the rtskb cache with some buffers (module parameter of rtnet.ko). As the socket creation also involves allocating a certain amount of packet buffers (rtskbs) and those buffers all have to be acquired from the same memory allocator (they have to be fully exchangeable), some pre-allocation is required in case the socket is opened in hard-RT context. This is where the rtskb cache comes into play: socket creation under RT takes the required rtskbs from this global cache. If it is empty - ENOMEM. For more details see Documentation/README.pools. Jan
signature.asc
Description: OpenPGP digital signature