Skip to contentSkip to conversation

is memcpy a system call?

DISCUSSION J.Hwan Kim 6 participants 7 messages Jun 8, 2012 – Jun 12, 2012

lore
Share & tools
lore

J.Hwan Kim

author
#0 lore raw

Hi, everyone

Is memcpy a system call?

Thanks in advnace,

Best Regards,
J.Hwna Kim

#1 lore raw
Quoted 5 lines

Is memcpy a system call?

Thanks in advnace,

memcpy is *not* a system call. It is a standard C library function.
System calls are those where you enter the kernel mode and ask your OS to do something for you (like read/write from disk).

For memory copy you don't need to take the service of OS.

#2 lore raw
In reply to J.Hwan Kim

Hi

Memcpy is both- a system call as well as a user library function. Implementation differs

Regards
Siddharth

Quoted 12 lines · J.Hwan Kim

Hi, everyone

Is memcpy a system call?

Thanks in advnace,

Best Regards,
J.Hwna Kim

Quoted 5 lines

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120608/4ed79d9e/attachment.html

#3 lore raw
Quoted 4 lines · siddharth saxena

Hi

Memcpy is both- a system call as well as a user library function. Implementation differs

Can you give me an example of memcpy being implemented as a syscall?

Thanks,
Jonathan Neusch?fer

#4 lore raw
In reply to siddharth saxena

Hi!

On Fre, 2012-06-08 at 20:51 +0530, siddharth saxena wrote:
[...]

Quoted 2 lines

Memcpy is both- a system call as well as a user library function. Implementation differs

What makes you believe this?

Bernd

Signature · 2 lines
Bernd Petrovitsch                  Email : bernd at petrovitsch.priv.at
                     LUGA : http://www.luga.at
#5 lore raw
In reply to J.Hwan Kim
Quoted 8 lines · J.Hwan Kim

Hi, everyone

Is memcpy a system call?

Thanks in advnace,

Best Regards,
J.Hwna Kim

"strace" is a good tool to find out which system calls a program is doing.

To answer your question, I don't think it makes much sense to implement memcpy as a syscall, because entering kernel mode is usually relatively expensive and I can't think of any kernel mode-only memcpy optimizations (and optimizations are the only reason to do a user space memcpy in kernel space I can think of).

HTH,
Jonathan Neusch?fer

#6 lore raw
In reply to J.Hwan Kim
Quoted 4 lines · J.Hwan Kim

Hi, everyone

Is memcpy a system call?

"Use the force, read the source"

uclibc:
http://git.uclibc.org/uClibc/tree/libc/string/generic/memcpy.c

glibc:
http://sourceware.org/git/?p=glibc.git;a=blob;f=string/memcpy.c;h=e167e85d7b31bda4e85ec7836631da2a15acf860;hb=c0da14cdda1fa552262ce3624156194eef43e973

Which means: No, memcpy (meaning the userspace function that gets included by "string.h") is *not* a system call.

Hope this helps,
Ezequiel.