EmbLogic's Blog

Character Device Driver

?The kernel offers several subroutines or functions in user space, which allow the end user application programmer to interact with the hardware. Usually, in UNIX or Linux systems, this dialogue is performed through functions or subroutines in order to read and write files. The reason for this is that in Unix devices are seen, from the point of view of the user, as files.
?On the other hand, in kernel space Linux also offers several functions or subroutines to perform the low level interactions directly with the hardware, and allow the transfer of information from kernel to user space.
?Usually, for each function in user space (allowing the use of devices or files), there exists an equivalent in kernel space (allowing the transfer of information from the kernel to the user and vice-versa). ?Scull is implemented on virtual disk having 8 register set. Application accesses the device through Kernel entry points available at user level. Any amount of data can  be read or written to scull depending on device size on character by character basis. 
Various operations can be  performed on the device. Device can be opened in append mode where user can write and read from any position. In read mode , any data can be read from the device from any position .In write mode, any data can be written to the  device from beginning , device will be treated as fresh device. Proc file system is used for debugging driver. Ioctl is implemented for changing device parameters . All we need to do is to pass the specification of device from the application. Synchronization Technique – Semaphore,Kernel Mutex , Blocking i/o , Completion , Poll, Spin-lock , Sequential locks,Big Kernel lock is used for multi-threaded application to avoid synchronization problem. Application is delayed before accessing scull using Kernel Timers. Kernel Timers along with Blocking i/o are used for delaying the application to access to device while the device  is getting ready.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>