Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Driver and IOCTL


    I have two queries related to driver and IOCTL....

    1. What is the difference between user space driver and kernel space driver
    2. Can we use control sequences(read, write, etc..) instead of IOCTL?
    If YES then y generally we opt IOCTL's
    If NO what is advantage of using IOCTL's or rather the diff between the two ?

    Please help


  2. #2
    Hi Pavan,

    1. As name suggest the user space drivers are drivers which do not reside in Kernel or which is not part of the kernel code. There are some issues that needs to be tackled when using user space drivers like how do we make sure that the user processes responds to the device interrupts and DMA handling. This is a micro kernel concept. Advantage of it is that debugging becomes very easy.
    The kernel space driver is a module that as name suggest is part of the kernel code. which is either loaded statically or dynamically. Care needs to be taken while writting kernel space driver as bugs introduced are very hard to detect.

    2. IOCTL can be termed as a general purpose or multi purpose system call which can used for variety of operations. read , write etc are system calls on the contrary have have well defined purpose.

    Hope that answers your question and correct me if I am wrong.

  3. #3
    Thanks for the reply,

    Regarding 1st query i am clear,
    2. As per my understanding the purpose of IOCTL is ....the device control or anything other than I/O ex: parameter setting for a hard drive etc....
    And i think we can control the device(any) .......using read the parameters (get) or write the parameters (set), then y do we go for IOCTL,
    Please let me know some more details regarding IOCTL's................

    Thanks in advance

  4. $spacer_open
  5. #4

    Purpose of IOCTL


    read/write are generally for reading / writing data stream.
    ioctl is for specific control operations.

    Taking the harddisk example:

    read/write - provide address and you can read /write data from/to harddisk at that location.
    ioctl - used to get/set the harddisk parameters - sector count, read-ahead feature etc.

    ioctl is expandable by adding additional opcodes.

    now to your question why: you can do all the get/set operations using read/write function calls. but if you do so you will add more confusion. Since, write accepts only stream of data, you will have to define a protocol between user space and kernel space with some structure (with a header containing opcode) etc etc. Now you will realize how ioctl makes life easy!!!!

    if you wish you can use only ioctl (without read/write) and only read/write (without ioctl) but with some compromises.

    I hope the above explanation helps you understand.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts