LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-27-2011, 01:38 AM   #1
manikumar086
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Rep: Reputation: Disabled
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...
 
Old 07-28-2011, 12:51 AM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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 .
 
Old 07-28-2011, 01:51 AM   #3
manikumar086
LQ Newbie
 
Registered: Jul 2011
Posts: 15

Original Poster
Rep: Reputation: Disabled
Question 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...
 
Old 07-28-2011, 10:33 AM   #4
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
Quote:
Originally Posted by manikumar086 View Post
*(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.
 
Old 07-29-2011, 01:28 AM   #5
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
You can create entries in /dev manually using the command "mknod" or kernel does the creation dynamically when it detects a device.
 
Old 07-29-2011, 09:22 AM   #6
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
hey bsat, if I want to mknod to create entries, where do I get the major and minor nos. needed from?
 
Old 07-30-2011, 01:34 PM   #7
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
@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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vmalloc or kmalloc for 16k memory space lorizhuang Linux - Kernel 3 06-14-2011 02:26 PM
Memory leaks.. *** glibc detected *** ./SuffixTree: malloc(): memory corruption: 0x00 evansash Programming 12 03-21-2011 01:17 PM
[SOLVED] Find Physical address of memory provided by kmalloc raghu2383 Programming 3 10-23-2009 02:25 PM
How Linux allocates memory for malloc in a program johnarg Linux - Newbie 2 06-25-2006 07:15 PM
malloc() and system memory spaceman27 Programming 8 04-25-2005 09:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration