[RTnet-developers] Re: [RTnet-users] about "context" in rtdm
Brought to you by:
bet-frogger,
kiszka
|
From: Jan K. <jan...@we...> - 2004-11-07 10:12:52
|
Zhang Yuchen wrote: > Hi, > in last 2 weeks, I made the progress in understanding of rtnet > internals. next week, I will switch back to firewire. > > But currently, I still have some unclear points in rtnet, one of > which is about the "context" in rtdm. To my current knowledge of > rtnet, rtdm is a kind of demultiplexer for operations of the devices > in its list. So when the standard API functions (BSD Socket) are > invoked, the rtdm first will examine the protocol family and socket > type to get the corresponding device, and then invoke the > corresponding operation.(Please fix me if I am wrong.) > Correct. BTW, the same applies to devices which are registered by a clear-text name (like the RTmac/TDMA discipline device "TDMAx"). > But why we need a "context" here? Since the "device" is fetched > during creating the socket, the other operations, like read_rt and > write_rt, can also be fetched via the prefetched device, right? Could > you please give me more explanation of the "context"? > The context stores information about the instance of the opened device like the caller's context (kernel/user), a usage counter, potentially overloaded device operations, and any device-specific data. In case the device allows only a single opener, these informations could also be stored together with the device structure. Actually, this is done for such devices by linking a single pre-allocated structure via exclusive_context. But if the device allows multiple instances at the same time as the protocol devices of RTnet do, you have to provide independent context structure which are created upon open. This allows to have e.g. several UDP ports to be used by different applications without interfering each other - as one expects it. Jan PS: rtn...@li... :) |