From: "Steven Smith" <sos22@cam.ac.uk>
To: davidgn@servidor.unam.mx
Cc: linux-c-programming@vger.kernel.org, sos22@srcf.ucam.org
Subject: Re: Linux source code: malloc.c
Date: Thu, 6 Jan 2005 16:10:29 +0000 [thread overview]
Message-ID: <20050106161029.GA6113@archibold> (raw)
In-Reply-To: <1105025253.41dd58e57c0f7@132.248.10.8>
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
> > > Where can I see the implementation of free() and malloc() in Linux
> > > source code? I am not able to locate the file malloc.c.
> > That's because malloc() isn't in Linux-the-kernel: it's in glibc.
> > The file you're looking for is malloc/malloc.c in the glibc tarball.
> Except the kernel implements its own "kmalloc", which if I'm not wrong is called
> upon by libc's malloc
Um, sort of... the kernel does implement a function kmalloc, but it's
not the same as the user-exposed one. For a start, memory allocated by
kmalloc is only accessible from kernel space, rather than user programs.
The kernel does provide two main primitives for userspace programs to
allocated memory: mmap and brk. These are both fairly limited,
though. mmap can only cope with multiples of the page size (4096
bytes on x86), while brk enforces a stack-like discipline.
sys_mmap and sys_brk do call upon kmalloc themselves, though.
Steven.
[-- Attachment #2: Type: application/pgp-signature, Size: 187 bytes --]
prev parent reply other threads:[~2005-01-06 16:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-23 13:14 Thread scheduling on an SMP Darío Mariani
2004-12-23 17:08 ` Richard Nairn
2004-12-24 13:14 ` file deletion Andy
2004-12-23 13:49 ` Jan-Benedict Glaw
2004-12-27 3:50 ` J.
2004-12-30 11:26 ` Glynn Clements
2004-12-30 12:04 ` wwp
2005-01-01 11:09 ` Andy
2004-12-31 17:55 ` Jan-Benedict Glaw
2005-01-06 7:07 ` Linux source code: malloc.c Venkatesh Joshi
2005-01-06 9:11 ` Steven Smith
2005-01-06 15:27 ` davidgn
2005-01-06 16:10 ` Steven Smith [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050106161029.GA6113@archibold \
--to=sos22@cam.ac.uk \
--cc=davidgn@servidor.unam.mx \
--cc=linux-c-programming@vger.kernel.org \
--cc=sos22@srcf.ucam.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.