LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Where does the Kmalloc/Vmalloc/get_free_pages/malloc Allocates memory? (https://www.linuxquestions.org/questions/linux-newbie-8/where-does-the-kmalloc-vmalloc-get_free_pages-malloc-allocates-memory-893987/)

manikumar086 07-27-2011 01:38 AM

Where does the Kmalloc/Vmalloc/get_free_pages/malloc Allocates memory?
 
Can any one help me and clarrify the below points:

1) Where does the Kmalloc/Vmalloc/get_free_pages/malloc Allocates memory in which space is it Kernel/User?

2) Coming to Hardware Point of View is where Kernel/User Space Memory Allocates is it in RAM or any.?

3) In Device Drivers, how Open Call get to know whether the hardware is connected/not?

Thanks in Adavance...

bsat 07-28-2011 12:51 AM

1) kmalloc/vmalloc/get_free_pages are used in module programming and allocate memory from kernel space where as malloc is used in application programming and hence allocates memory in user space.

2) Yes all the memory allocation happens in RAM.

3) All the devices that are connected to the system get listed in /dev so the driver can open only devices that are listed in /dev .

manikumar086 07-28-2011 01:51 AM

how /dev have the entries of devices connected
 
Hi bsat thanx for the reply...

as you told that 'All the devices that are connected to the system get listed in /dev so the driver can open only devices that are listed in /dev'

*(might this sounds like stupid but i want to clarify that) how even that /dev have the entries of devices connected...

resetreset 07-28-2011 10:33 AM

Quote:

Originally Posted by manikumar086 (Post 4427342)
*(might this sounds like stupid but i want to clarify that) how even that /dev have the entries of devices connected...



The kernel does that.

bsat 07-29-2011 01:28 AM

You can create entries in /dev manually using the command "mknod" or kernel does the creation dynamically when it detects a device.

resetreset 07-29-2011 09:22 AM

hey bsat, if I want to mknod to create entries, where do I get the major and minor nos. needed from?

bsat 07-30-2011 01:34 PM

@resetreset Once you insmod the module, it should appear in /proc/devices. So if you

cat /proc/device | cat "module name" ( name used in the call alloc_chrdev_region)

The first column should give you the major number.

The minor numbers generally start from "0" in increasing order as you connect more devices to be controlled by the driver.


All times are GMT -5. The time now is 12:29 AM.