InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Where Can We Write Allocation And Freeing Of Device Number's Code ? |
|
Answer» allocation : init FUNCTION of a MODULE FREEING : cleanup function of a module allocation : init function of a module freeing : cleanup function of a module |
|
| 2. |
What Is The Disadvantage Of Dynamic Device Number Assignment ? |
|
Answer» The disadvantage of DYNAMIC assignment is that you can't create the device nodes in advance, because the major NUMBER assigned to your module will VARY. The disadvantage of dynamic assignment is that you can't create the device nodes in advance, because the major number assigned to your module will vary. |
|
| 3. |
How To See Statically Assigned Major Numbers ? |
|
Answer» Some MAJOR DEVICE numbers are statically assigned to the most common devices. A list of those devices can be found in Documentation/devices.txt WITHIN the kernel source tree. Some major device numbers are statically assigned to the most common devices. A list of those devices can be found in Documentation/devices.txt within the kernel source tree. |
|
| 4. |
How Can I Use My Own Major And Minor Number For A Device File ? |
|
Answer» if you have the MAJOR and MINOR NUMBERS and need to turn them into a dev_t, use: register_chrdev_region works well if you know ahead of time exactly which device numbers you want. Often, however, you will not know which major numbers your device will use; there is a constant effort WITHIN the Linux KERNEL development community to move over to the use of dynamically-allocated device numbers. if you have the major and minor numbers and need to turn them into a dev_t, use: register_chrdev_region works well if you know ahead of time exactly which device numbers you want. Often, however, you will not know which major numbers your device will use; there is a constant effort within the Linux kernel development community to move over to the use of dynamically-allocated device numbers. |
|
| 5. |
How To Retrieve Major And Minor Number From Dev_t Type ? |
|
Answer» To OBTAIN the major or minor NUMBER of a dev_t, USE: MAJOR(dev_t dev); // to obtain major number MINOR(dev_t dev); // to obtain minor number INT major=MAJOR(dev_t dev); int minor =MINOR(dev_t dev); To obtain the major or minor number of a dev_t, use: MAJOR(dev_t dev); // to obtain major number MINOR(dev_t dev); // to obtain minor number int major=MAJOR(dev_t dev); int minor =MINOR(dev_t dev); |
|
| 6. |
What Is Use Of Dev_t Type ? |
|
Answer» This is USED to hold DEVICE numbers—both the major and minor PARTS. This is used to hold device numbers—both the major and minor parts. |
|
| 7. |
What Is Range Of Major And Minor Numbers? |
|
Answer» 0-255 0-255 |
|
| 8. |
What Is Minor Number And It's Usage ? |
|
Answer» The minor number is used only by the DRIVER itself to DIFFERENTIATE which DEVICE it's operating on, just in case the driver handles more than one device. (or) one driver can control more than one device .minor will be used to distinguish the one device from other DEVICES . The minor number is used only by the driver itself to differentiate which device it's operating on, just in case the driver handles more than one device. (or) one driver can control more than one device .minor will be used to distinguish the one device from other devices . |
|
| 9. |
Can We Have Same Major Number For More Than One Device File ? |
|
Answer» YES . we can have . yes . we can have . |
|
| 10. |
What Is Major Number And It's Usage ? |
|
Answer» It's an INTEGER number MAINLY used to provide the association between the DEVICE driver and device file . this number is used by kernel . (or) The major number TELLS you which driver HANDLES which device file. It's an integer number mainly used to provide the association between the device driver and device file . this number is used by kernel . (or) The major number tells you which driver handles which device file. |
|
| 11. |
How Can We Free Device Numbers ? |
|
Answer» VOID unregister_chrdev_region(dev_t FIRST, UNSIGNED INT COUNT); void unregister_chrdev_region(dev_t first, unsigned int count); |
|
| 12. |
How Can We Allocate Device Number Dynamically ? |
|
Answer» alloc_chrdev_region()will dynamically allocate device numbers. int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int COUNT, char *name); Here
alloc_chrdev_region()will dynamically allocate device numbers. int alloc_chrdev_region(dev_t *dev, unsigned int firstminor, unsigned int count, char *name); Here |
|
| 13. |
How Can We Allocate Device Number Statically ? |
|
Answer» register_chrdev_region() FUNCTION will statically allocate DEVICE numbers. which is declared in <linux/fs.h> INT register_chrdev_region(dev_t first, unsigned int count, char *name); Return values : In case of success "0" will return , In case of failure "-1 or negative value " will return Here
register_chrdev_region() function will statically allocate device numbers. which is declared in <linux/fs.h> int register_chrdev_region(dev_t first, unsigned int count, char *name); Return values : In case of success "0" will return , In case of failure "-1 or negative value " will return Here |
|
| 14. |
In How Many Ways We Can Allocate Device Number ? |
|
Answer» In 2 WAYS we can ALLOCATE device NUMBERS
In 2 ways we can allocate device numbers |
|
| 15. |
What Is Mknod And It's Usage ? |
|
Answer» mknod is a command which used CREATE the device file (or) node in Linux file SYSTEM. In unix or linux we will REPRESENT everything as a file . syntax: mknod Name { b | c } Major MINOR Name : name of the device file { b | c } : type of device (ex; char or BLOCK device) Major : Major number of the device file Minor : Minor number of the device file ex : $ mknod /dev/rama c 12 5 MKDEV(int major, int minor); mknod is a command which used create the device file (or) node in Linux file system. In unix or linux we will represent everything as a file . syntax: mknod Name { b | c } Major Minor Name : name of the device file { b | c } : type of device (ex; char or block device) Major : Major number of the device file Minor : Minor number of the device file ex : $ mknod /dev/rama c 12 5 MKDEV(int major, int minor); |
|