当前位置: 技术问答>linux和unix
在linux内核的轻量进程如何写?
来源: 互联网 发布时间:2015-05-04
本文导语: 如此 | linux内核的轻量进程--pthread pthread实现: int do_fork(unsigned long clone_flags, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size) 这里的clone_flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_...
如此
|
linux内核的轻量进程--pthread
pthread实现:
int do_fork(unsigned long clone_flags, unsigned long stack_start,
struct pt_regs *regs, unsigned long stack_size)
这里的clone_flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND。
pthread实现:
int do_fork(unsigned long clone_flags, unsigned long stack_start,
struct pt_regs *regs, unsigned long stack_size)
这里的clone_flags = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND。
|
Linux的内核轻量级线程是pthread么?好像不是吧?
内核级进程应该是没有自己的内存映射的进程吧?
内核级进程应该是没有自己的内存映射的进程吧?
|
LinuxThreads不一定是Pthread!
但是我只领悟到这一层,不知道还有没有其他的形式
能介绍介绍它们的实现吗?
但是我只领悟到这一层,不知道还有没有其他的形式
能介绍介绍它们的实现吗?
|
在linux内核的轻量进程就是线程了。
创建:int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *
(*start_routine)(void *), void * arg);
DESCRIPTION
pthread_create creates a new thread of control that executes concur-
rently with the calling thread. The new thread applies the function
start_routine passing it arg as first argument. The new thread termi-
nates either explicitly, by calling pthread_exit(3), or implicitly, by
returning from the start_routine function. The latter case is equiva-
lent to calling pthread_exit(3) with the result returned by start_rou-
tine as exit code.
The attr argument specifies thread attributes to be applied to the new
thread. See pthread_attr_init(3) for a complete list of thread
attributes. The attr argument can also be NULL, in which case default
attributes are used: the created thread is joinable (not detached) and
has default (non real-time) scheduling policy.
RETURN VALUE
On success, the identifier of the newly created thread is stored in the
location pointed by the thread argument, and a 0 is returned. On error,
a non-zero error code is returned.
创建:int pthread_create(pthread_t * thread, pthread_attr_t * attr, void *
(*start_routine)(void *), void * arg);
DESCRIPTION
pthread_create creates a new thread of control that executes concur-
rently with the calling thread. The new thread applies the function
start_routine passing it arg as first argument. The new thread termi-
nates either explicitly, by calling pthread_exit(3), or implicitly, by
returning from the start_routine function. The latter case is equiva-
lent to calling pthread_exit(3) with the result returned by start_rou-
tine as exit code.
The attr argument specifies thread attributes to be applied to the new
thread. See pthread_attr_init(3) for a complete list of thread
attributes. The attr argument can also be NULL, in which case default
attributes are used: the created thread is joinable (not detached) and
has default (non real-time) scheduling policy.
RETURN VALUE
On success, the identifier of the newly created thread is stored in the
location pointed by the thread argument, and a 0 is returned. On error,
a non-zero error code is returned.
|
你好象已经用pthread_create写过了.我也参加讨论了.
现在还有问题吗?
现在还有问题吗?