Re: processes, tasks, threads
Re: processes, tasks, threads
- Subject: Re: processes, tasks, threads
- From: Mo McRoberts <email@hidden>
- Date: Mon, 12 Apr 2010 14:43:34 +0100
On 10-Apr-2010, at 17:09, Jens Alfke wrote:
> A thread is just a flow of control -- a CPU state (registers) and a stack.
> A process is what you think of as a program, what's listed in 'top' or Activity Monitor. It's a set of threads running in a memory address space plus a set of privileges (user and group ID, resource quotas, etc.)
> "Task" is I think a synonym for process. I haven't heard "flow" before, but I'd guess it means the same as thread.
>
> The above definitions hold for pretty much every OS, including Linux.
not quite… last time I worked with it, on Linux a (kernel) thread was not materially different from a process, except that it shares memory/resources with the 'main thread' process rather than doing COW as it would if you'd forked and has a flag to say "I'm a thread". Linux has a slightly unusual syscall - clone(2) - which lets you create a process with rather fine-grained control over which things are newly-allocated, which are COW, and which are shared. kernel threads are created on Linux by way of clone(…, CLONE_THREAD…), which puts the new process in the same “thread group” as the parent (to bias scheduling). internally to the kernel, sys_fork(), sys_vfork() and sys_clone() all just call do_fork() (defined in kernel/fork.c), which handles the meat of creating new processes, whether they be threads or otherwise.
the linux kernel does have 'kthreads' as well, but these are threads internal to the kernel itself and not created by userland processes.
M.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden