driver ring buffer overrun and printf usage

Amit Nagal helloin.amit at gmail.com
Thu Jul 14 08:20:49 EDT 2011


Hi ,

In my embedded linux-arm target , in a userspace thread , i am reading
hid events over usb-hiddev interface (/dev/hiddev) .

basically what i do  is this :

read_thread(){
while(1){
ret = read( "/dev/hiddev" , user_buffer , bytes_to_read);
printf("bytes received =%d" , ret ) ;  // (printf prints debug message
to serial console  );
}
}

now whenever i use the printf statement in read thread ,  kernel space
ring buffer  in usb-hid driver is overrun frequently , which results
in loss of data send by usb device .
if i remove printf in read thread , no overruns are reported in
usb-hid driver . that means if  printf is used , application
read_thread is not able to
read data in time which leads to driver ring buffer overrun .

does this behaviour of printf points to some problem in embedded
linux's  scheduler  ( printf prints data to debug serial port , and
consecutive read() calls in  read_thread() are  scheduled lately due
to that ) ?

do the actual implementation of printf  involves any kind of sleeps ?

kindly share necessary insight wrt above printf usage and driver ring
buffer overrun .

regards
Amit Nagal



More information about the Kernelnewbies mailing list