1

I am calling a driver function from application by using an ioctl(). By using logs i found that my kernel code is executing first. for example,

In my application

printf("Calling Driver"); ioctl();

In my driver

printk("Driver called");

When i execute my code, first it is printing "Driver called" and then "Calling Driver" I there any reason for this?

linuxchip
  • 316
  • 1
  • 5

1 Answers1

0

By default, the stdout stream is buffered, and the datas are only displayed after a newline (or the end of execution). In this case, the display is done after the ioctl call.

Your can force the display using fflush after your printf call.

printf("Calling Driver");
fflush(stdout);
ioctl();

For more details, you can read these answers.

Community
  • 1
  • 1
BAK
  • 934
  • 8
  • 23