Welcome to Soft32 Linux Forums!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

where 's the location of the implementation of mlock metho..

 
   Soft32 Home -> Linux -> App Development RSS
Next:  [Samba] Memory usage  
Author Message
sods

External


Since: Aug 21, 2007
Posts: 7



(Msg. 1) Posted: Mon Aug 20, 2007 8:02 pm
Post subject: where 's the location of the implementation of mlock method under linux & glibc?
Archived from groups: comp>os>linux>development>apps (more info?)

Hi ,

I'm using the mlock() to lock pages,
and search the glibc-2.3.6 source code for its implementation.
but i get nothing expect a general dummy definition and a hurd
implementation.

Where is the linux i386 version of mlock implementation ?
is it in kernel? which file, doesn't glibc wrap the mlock if it is
in kernel ?

Thanks
sods
Back to top
Login to vote
Paul Pluzhnikov

External


Since: Nov 19, 2003
Posts: 37



(Msg. 2) Posted: Tue Aug 21, 2007 2:40 pm
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

sods <skyofdreams RemoveThis @gmail.com> writes:

> I'm using the mlock() to lock pages,
> and search the glibc-2.3.6 source code for its implementation.
> but i get nothing expect a general dummy definition and a hurd
> implementation.
>
> Where is the linux i386 version of mlock implementation ?

From ChangeLog.5 in glibc-2.5 sources:

Thu Jan 18 00:32:43 1996 Roland McGrath <roland RemoveThis @churchy.gnu.ai.mit.edu>
....
Replaced all simple system call files *.S throughout sysdeps/unix
with syscalls.list files to be processed by make-syscalls.sh.
....
* sysdeps/unix/sysv/linux/mlock.S: File removed.

> is it in kernel?

There is sys_mlock() in the kernel, but that has nothing whatsoever to do
with glibc mlock syscall wrapper.

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Back to top
Login to vote
sods

External


Since: Aug 21, 2007
Posts: 7



(Msg. 3) Posted: Tue Aug 21, 2007 7:08 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 22, 10:40 am, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > I'm using the mlock() to lock pages,
> > and search the glibc-2.3.6 source code for its implementation.
> > but i get nothing expect a general dummy definition and a hurd
> > implementation.
>
> > Where is the linux i386 version of mlock implementation ?
>
> From ChangeLog.5 in glibc-2.5 sources:
>
> Thu Jan 18 00:32:43 1996 Roland McGrath <rol....TakeThisOut@churchy.gnu.ai.mit.edu>
> ...
> Replaced all simple system call files *.S throughout sysdeps/unix
> with syscalls.list files to be processed by make-syscalls.sh.
> ...
> * sysdeps/unix/sysv/linux/mlock.S: File removed.
>
Thanks.

it's a good point.
and
this implementation is really a little magic.

> > is it in kernel?
>
> There is sys_mlock() in the kernel, but that has nothing whatsoever to do
> with glibc mlock syscall wrapper.

I do some findings.
all method in syscalls.list are "compiled" into object file in
glibc-build/misc/
--
glibc-build/misc/mlock.o
glibc-build/misc/mlockall.o
--

and finally link into libc.os.6, so
libc.so.6 have mlock in .text section.
--
00bc0d0 T mlock
000bc150 T mlockall
--

so , the mlock in libc.so.6 is a wrapper? should be,
but the mechanism of this wrapper is still unclear.

-sods
Back to top
Login to vote
Paul Pluzhnikov

External


Since: Nov 19, 2003
Posts: 37



(Msg. 4) Posted: Wed Aug 22, 2007 2:30 pm
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

sods <skyofdreams.TakeThisOut@gmail.com> writes:

> so , the mlock in libc.so.6 is a wrapper?

Yes, it's a wrapper for the syscall:

0x000ba000 <mlock+0>: mov %ebx,%edx # %ebx must be preserved
0x000ba002 <mlock+2>: mov 0x8(%esp),%ecx # load second arg into %ecx
0x000ba006 <mlock+6>: mov 0x4(%esp),%ebx # load first arg into %ebx
0x000ba00a <mlock+10>: mov $0x96,%eax # 0x96 == 150 == __NR_mlock /usr/include/asm/unistd.h
0x000ba00f <mlock+15>: int $0x80 # syscall

> but the mechanism of this wrapper is still unclear.

It's unclear to me what's unclear to you.

Did you read make-syscalls.sh? Did you understand what it does?

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Back to top
Login to vote
sods

External


Since: Aug 21, 2007
Posts: 7



(Msg. 5) Posted: Wed Aug 22, 2007 6:21 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 23, 10:30 am, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > so , the mlock in libc.so.6 is a wrapper?
>
> Yes, it's a wrapper for the syscall:
>
> 0x000ba000 <mlock+0>: mov %ebx,%edx # %ebx must be preserved
> 0x000ba002 <mlock+2>: mov 0x8(%esp),%ecx # load second arg into %ecx
> 0x000ba006 <mlock+6>: mov 0x4(%esp),%ebx # load first arg into %ebx
> 0x000ba00a <mlock+10>: mov $0x96,%eax # 0x96 == 150 == __NR_mlock /usr/include/asm/unistd.h
> 0x000ba00f <mlock+15>: int $0x80 # syscall
>

yes, it's more clear from asm code.
just a simple wrapper.

> > but the mechanism of this wrapper is still unclear.
>
> It's unclear to me what's unclear to you.
>
> Did you read make-syscalls.sh? Did you understand what it does?
>

I have readed it now. Smile

it's the make-syscalls.sh where the magic is in.

Makefile use it to create another script call sysd-syscallT, which
then do the actual operations.
sysd-syscallT seems generate the c source wrapper code, and pass them
to gcc through pipe. (.. pipe so no mlock.c file.)

but it all doesn't matter ,
I want to know what logic is processed when i call mlock.
If the glibc just a simple wrapper, all actual case should happen in
kernel.

now, i know it's in kernel, i 'll dip into kernel a little , e.g.
learn how trap works
to contnue.

thanks, for the help.
-sods

> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email.
Back to top
Login to vote
Paul Pluzhnikov

External


Since: Nov 19, 2003
Posts: 37



(Msg. 6) Posted: Thu Aug 23, 2007 2:19 am
Post subject: Re: where 's the location of the implementation of mlock method [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

sods <skyofdreams RemoveThis @gmail.com> writes:

> I want to know what logic is processed when i call mlock.

If you want to understand the logic for *any* system call, you have
to look in the kernel -- that's where the code for them resides
(and that's what makes them 'system call', as opposed to libc calls).

> now, i know it's in kernel, i 'll dip into kernel a little , e.g.
> learn how trap works to contnue.

If you want to understand what mlock does, start with sys_mlock
in /usr/src/linux-X.Y/mm/mlock.c (it's somewhat long way from how
trap works, you can just assume that int80 with %eax==150 eventually
gets to sys_mlock in the kernel).

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
Back to top
Login to vote
sods

External


Since: Aug 21, 2007
Posts: 7



(Msg. 7) Posted: Thu Aug 23, 2007 12:59 pm
Post subject: Re: where 's the location of the implementation of mlock method under linux & glibc? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Aug 23, 10:19 pm, Paul Pluzhnikov <ppluzhnikov-....TakeThisOut@charter.net>
wrote:
> sods <skyofdre....TakeThisOut@gmail.com> writes:
> > I want to know what logic is processed when i call mlock.
>
> If you want to understand the logic for *any* system call, you have
> to look in the kernel -- that's where the code for them resides
> (and that's what makes them 'system call', as opposed to libc calls).

Yeah, you're right,

Several day ago, i thought libc calls have some 'real' logic to
wrap the system call.
but seems this doesn't happen to mlock.

>
> > now, i know it's in kernel, i 'll dip into kernel a little , e.g.
> > learn how trap works to contnue.
>
> If you want to understand what mlock does, start with sys_mlock
> in /usr/src/linux-X.Y/mm/mlock.c (it's somewhat long way from how
> trap works, you can just assume that int80 with %eax==150 eventually
> gets to sys_mlock in the kernel).

Thanks, i'll try to read the mm/mlock.c@sys_mlock
i guess if i meet more problems, the help topic should appear on
comp.os.linux.system. Wink

Thank for your help, again.
-sods


>
> Cheers,
> --
> In order to understand recursion you must first understand recursion.
> Remove /-nsp/ for email.
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How can i register a link protocol for browsers - I want to add an action to the system so that every time a user clicks in a link with for example ..

storing the data in ln2440 target board memory - hai.. i using the target board ln2440sbc..and linux OS.. (16Mb flash and 32Mb sdram) i have cross compiled and porte...

GTK run error - hi i had created one same application in glad interface designer with c option.the n i compiled the same after that i....

C++ -> mplayer, stdin, stdout, popen / fork / pipe... - Hello everybody. I tried to work this out on my own for about 6 hours non-stop now and I just don't get it working.......

[RFC] Track mlock()ed pages - Add NR_MLOCK Track mlocked pages via a ZVC Signed-off-by: Christoph Lameter <clameter@sgi.com> Index:..

[debian-hurd-Patches][303057] #349204: libc0.3: mlock() fa.. - Patches item #303057, was opened at 2006-02-15 19:31 >Status: Closed Priority: 3 Submitted By: Samuel Thibault..
       Soft32 Home -> Linux -> App Development All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Categories:
 Windows
  Linux
 Mac
 PDA


[ Contact us | Terms of Service/Privacy Policy ]