clone (Linux system call)

clone (Linux system call)

clone() is a system call on the Linux kernel related to multithreading. In practice, one should try to avoid calling clone() directly, but instead use a threading library (such as pthreads) which use clone() when starting a thread (such as during a call to pthread_create()).

The syntax for calling clone under a Linux program is:

 #include <sched.h>
 int clone (int (*fn) (void *), void *child_stack, int flags, void *arg);

clone creates a new thread that starts with the function pointed to by the fn argument (as opposed to fork() which continues with the next command after fork().) The child_stack argument is a pointer to a memory space to be used as the stack for the new thread (which must be malloc'ed before that; on most architectures stack grows down, so the pointer should point at the end of the space), flags specify what gets inherited from the parent process, and arg is the argument passed to the function. It returns the process ID of the child process or -1 on failure.

See also


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Clone (Linux system call) — clone() is a system call on the Linux kernel related to multithreading.The syntax for calling clone under a Linux program is: #include int clone (int (*fn) (void *), void *child stack, int flags, void *arg);clone creates a new thread that starts… …   Wikipedia

  • Clone — Contents 1 Biological 2 Computing 3 Entertainment 3.1 Music …   Wikipedia

  • Clone (function) — The clone() function may be: * clone (Linux system call), in C, relating to multithreading * clone (Java method), in Java, used for object duplicationee also* Clone …   Wikipedia

  • Lista de videojuegos en Linux — Esta página o sección está siendo traducida del idioma inglés a partir del artículo Linux gaming, razón por la cual puede haber lagunas de contenidos, errores sintácticos o escritos sin traducir. Puedes colaborar con Wikipedia …   Wikipedia Español

  • History of Linux — The Linux kernel has been marked by constant growth throughout its history. Since the initial release of its source code in 1991, it has grown from a small number of C files under a license prohibiting commercial distribution to its state in 2007 …   Wikipedia

  • Thread (computer science) — This article is about the concurrency concept. For the multithreading in hardware, see Multithreading (computer architecture). For the form of code consisting entirely of subroutine calls, see Threaded code. For other uses, see Thread… …   Wikipedia

  • Richard Stallman — Richard Matthew Stallman Richard Stallman at the University of Pittsburgh 2010 Born March 16, 1953 (1953 03 16) (age 58) New York City, New York …   Wikipedia

  • Native POSIX Thread Library — The Native POSIX Thread Library (NPTL) is a software feature that enables the Linux kernel to run programs written to use POSIX Threads efficiently. Contents 1 History 2 Design 3 See also 4 References …   Wikipedia

  • Process management (computing) — Operating systems …   Wikipedia

  • OS/2 — A typical OS/2 Warp 4 desktop Company / developer IBM Microsoft …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”