|
Home > Archive > Unix Programming > September 2005 > threads and processes
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
threads and processes
|
|
| rahul8143@gmail.com 2005-09-18, 7:47 am |
| hello,
How linux schedules,executes processes and threads with respect to
OS? I mean if say process A is executing then if it creates 2 threads
and similaraly there are other processes in system currently then how
OS schedules them?
Also does each thread of a process has a its PID? Does in a
multithreaded program all its threads have PID?
regards,
rahul
| |
| Kasper Dupont 2005-09-18, 5:55 pm |
| rahul8143@gmail.com wrote:
>
> hello,
> How linux schedules,executes processes and threads with respect to
> OS? I mean if say process A is executing then if it creates 2 threads
> and similaraly there are other processes in system currently then how
> OS schedules them?
They are scheduled like all other threads on the system.
Each thread get a time slice, the higher the nice value is
the shorter a slice the thread gets. The scheduler will try
to give threads sharing address space their slices just after
each other to reduce the number of TLB flushes.
> Also does each thread of a process has a its PID? Does in a
> multithreaded program all its threads have PID?
Each thread have an ID, not all people agree on what to call
that ID. You can get both the ID of the individual thread and
the ID of the group. The getpid() system call used to give
the ID of the thread, but in newer kernels give the ID of the
group.
--
Kasper Dupont
Note to self: Don't try to allocate
256000 pages with GFP_KERNEL on x86.
|
|
|
|
|