On Thu, Jul 16, 2020 at 1:21 PM Michel Macena Oliveira <michel@xxxxxxxxxxxxxxxxxxxx> wrote: > > Em qui., 16 de jul. de 2020 às 16:26, Itai Handler > <itai.handler@xxxxxxxxx> escreveu: > > > > Hi Michel, > > > > On 7/16/20, Michel Macena Oliveira <michel@xxxxxxxxxxxxxxxxxxxx> wrote: > > > Hi, sorry for my newbie question, > > > What is the status of the serial port driver? > > > I've written some code to use serial ports for the generic kernel linux, > > > And now I want to write something similar for the real time kernel, do > > > I have to use some specific library, flags or something or is it just > > > the same settings? > > > > > > I'm asking because now I need to take into account the serial access > > > in the scheduler to ensure a real time behavior . > > > > > > Any help, advice, hint or tips would be appreciated. > > > > > > > Do you mean that you wrote some code that works with a /dev/tty* serial port? > > > > In some kernel versions (e.g 4.19) we saw high latencies in the rx > > path of serial drivers. > > I think that this is due to rx handled in the context of a workqueue > > which also handles other system activities. > > We found a workaround to this problem. If I remember correctly we > > create a dedicated thread for the port and assign it a high priority. > > > > Itai Handler > > Thanks for the answer, > Yes I wrote a code that works with /dev/tty* serial using termios.h. > I thought exactly what you suggested, to use a dedicated thread, but > how to properly implement it? > I mean in a simple way, just need to put open and write calls inside > the high priority (RT) thread? > > Current kernel: 4.4.208-rt198 #1 SMP PREEMPT RT Itai is talking about the kernel work to handle the serial data, not the userspace work. We found the same thing, that the work goes through a work queue in the kernel, which adds unbounded latency. https://www.spinics.net/lists/linux-serial/msg07341.html looks relevant and matches my memory of what we did to solve this. There's either a flag in userspace or patch to apply to the kernel (and then a flag) to skip the work queue. Austin