YouTube Icon

Interview Questions.

Top 100+ Linux Device Drivers Interview Questions And Answers - May 31, 2020

fluid

Top 100+ Linux Device Drivers Interview Questions And Answers

Question 1. What Is Mknod And It's Usage ?

Answer :

mknod is a command  which used create the tool report (or) node in Linux file system.

In unix or linux we are able to constitute the whole lot as a document .

Syntax: mknod Name  b   Major  Minor

Name : name of the device document

 c  : form of tool (ex; char or block tool)

Major  : Major wide variety of the device report

Minor  : Minor range of the device record

ex : $  mknod /dev/rama  c  12  5

MKDEV(int principal, int minor);

Question 2. In How Many Ways We Can Allocate Device Number ?

Answer :

In 2 ways we will allocate tool numbers

statically
dynamically
Python Interview Questions
Question 3. How Can We Allocate Device Number Statically ?

Answer :

register_chrdev_region() feature will statically allocate tool numbers. Which is said in <linux/fs.H>

int register_chrdev_region(dev_t first, unsigned int rely, char *call);

Return values : In case of success "zero" will return , In case of failure  "-1 or poor value " will go back 

Here

first is the beginning tool quantity of the range you would love to allocate. The minor number portion of first is regularly zero.
Depend is the full number of contiguous tool numbers you're asking for.
Call is the call of the tool that have to be associated with this variety variety. It will appear in /proc/devices and sysfs.
Question four. How Can We Allocate Device Number Dynamically ?

Answer :

alloc_chrdev_region()will dynamically  allocate tool numbers.

Int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, 

                        unsigned int remember, char *call);

Here

dev is an output-best parameter with a purpose to, on successful of entirety, preserve the primary number on your allocated variety. 
Firstminor have to be the requested first minor wide variety to apply; it is also zero
be counted is the full wide variety of contiguous tool numbers you are soliciting for.
Call is the call of the tool that ought to be associated with this variety variety. It'll appear in /proc/gadgets and sysfs.
Python Tutorial
Question 5. How Can We Free Device Numbers ?

Answer :

void unregister_chrdev_region(dev_t first, unsigned int matter);

Embedded Systems Interview Questions
Question 6. What Is Major Number And It's Usage ?

Answer :

It's an  integer wide variety  particularly used to provide the affiliation among the tool motive force and tool report . This number is used by kernel .

                (or)

The major variety tells you which of them motive force handles which tool report. 

Question 7. Can We Have Same Major Number For More Than One Device File ?

Answer :

yes . We will have .

Linux Tutorial Linux Interview Questions
Question eight. What Is Minor Number And It's Usage ?

Answer :

The minor range is used most effective by the driver itself to distinguish which tool it is operating on, simply in case the driving force handles a couple of tool.

(or)

one motive force can manage a couple of device .Minor might be used to differentiate the one tool from other devices   .

Question nine. What Is Range Of Major And Minor Numbers?

Answer :

zero-255

Linux Embedded systems Interview Questions
Question 10. What Is Use Of Dev_t Type ?

Answer :

This is used to hold device numbers—both the foremost and minor components.

Linux Embedded structures Tutorial
Question eleven. How To Retrieve Major And Minor Number From Dev_t Type ?

Answer :

To reap the predominant or minor number  of a dev_t, use:

MAJOR(dev_t dev); // to obtain essential wide variety

MINOR(dev_t dev);  // to obtain minor variety

int important=MAJOR(dev_t dev);

int minor =MINOR(dev_t dev);

Software Engineering Interview Questions
Question 12. How Can I Use My Own Major And Minor Number For A Device File ?

Answer :

when you have the primary and minor numbers and need to show them right into a dev_t, use:

register_chrdev_region works properly in case you realize beforehand of time exactly which device numbers you want. Often, however, you will not recognize which primary numbers your device will use; there is a constant effort within the Linux kernel improvement network to transport over to using dynamically-allotted tool numbers.

Python Interview Questions
Question thirteen. How To See Statically Assigned Major Numbers ?

Answer :

Some essential tool numbers are statically assigned to the maximum not unusual devices. A list of those devices can be observed in Documentation/gadgets.Txt in the kernel source tree.

Software Engineering Tutorial
Question 14. What Is The Disadvantage Of Dynamic Device Number Assignment ?

Answer :

The downside of dynamic project is which you can not create the tool nodes earlier, due to the fact the fundamental variety assigned to your module will vary.

Question 15. Where Can We Write Allocation And Freeing Of Device Number's Code ?

Answer :

allocation : init feature of a module

freeing : cleanup feature of a module

Git (software) Interview Questions




CFG