Skip to contentSkip to conversation

About PID...???!!!

DISCUSSION Silambu Chelvan 4 participants 8 messages Sep 10, 2003

lore
Share & tools
lore
#0 lore raw

Hi All,

I have been using linux for quite some time. I wonder how the PID is assigned by the kernel. Is there anything like range of PID for each user? In my machine I could see PIDs of 256, 389, 413 etc. Does this mean that there are almost 413 processes running?

Please explain.....

with regards,
M. SilambuChelvan

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#1 lore raw

They are assigned linearly, however once a pid is used, it is never reused until the machine reboots.

A pid of 413 means that when that process was fork()'ed there had been 412 other processes already created. But remember every time you type ls, you've run a process.

413 isn't a large pid at all. My linux box which I very rarely reboot is at PIDs that start at 20000

I'm surprised that any program you start after the boot process is as low as 412.

----- Original Message -----
From: "Silambu Chelvan" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 10:23 AM
Subject: About PID...???!!!

Quoted 13 lines

Hi All,

I have been using linux for quite some time. I wonder how the PID is assigned by the kernel. Is there anything like range of PID for each user? In my machine I could see PIDs of 256, 389, 413 etc. Does this mean that there are almost 413 processes running?

Please explain.....

with regards,
M. SilambuChelvan

Quoted 9 lines

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#2 lore raw
Quoted 2 lines · John T. Williams

They are assigned linearly, however once a pid is used, it is never reused until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think* at 32767 (or maybe 65535). Next time around, the kernel skips over any pids that are still in use from the last round of assignment.

Quoted 9 lines

A pid of 413 means that when that process was fork()'ed there had been 412 other processes already created. But remember every time you type ls, you've run a process.

413 isn't a large pid at all. My linux box which I very rarely reboot is at PIDs that start at 20000

I'm surprised that any program you start after the boot process is as low as 412.

Whether that is surprising or not depends on what he uses the host for and, naturally, on how recently it was rebooted. While my workstation is way up there (30180), my Linux-based router, which does not start new processes very much, is only at pid 828.

And, of course, there are persistent processes on any Linux host that go back to the boot/init process ... starting with init itself (always pid 1) and including long-lived daemons such as syslogd, klogd, and portmap; pseudo processes that are actually run in the kernel (mostly [k*] process names); and getty proceses listening on VTs that never get logins.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#3 lore raw

definitely higher then 2^16, I've got a process with the PID of 69917 I would guess MAX_INT which is 2^32 -1 = 4294967295

----- Original Message -----
From: "Ray Olszewski" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 11:58 AM
Subject: Re: About PID...???!!!

Quoted 2 lines
Quoted 1 line · John T. Williams

They are assigned linearly, however once a pid is used, it is never

reused

Quoted 7 lines
Quoted 1 line

until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think* at 32767 (or maybe 65535). Next time around, the kernel skips over any pids that are still in use from the last round of assignment.

Quoted 1 line

A pid of 413 means that when that process was fork()'ed there had been

412

Quoted 1 line
Quoted 1 line

other processes already created. But remember every time you type ls,

you've

Quoted 3 lines
Quoted 3 lines

run a process.

413 isn't a large pid at all. My linux box which I very rarely reboot is

at

Quoted 3 lines
Quoted 3 lines

PIDs that start at 20000

I'm surprised that any program you start after the boot process is as low

as

Quoted 3 lines
Quoted 1 line

412.

Whether that is surprising or not depends on what he uses the host for

and,

Quoted 12 lines

naturally, on how recently it was rebooted. While my workstation is way up there (30180), my Linux-based router, which does not start new processes very much, is only at pid 828.

And, of course, there are persistent processes on any Linux host that go back to the boot/init process ... starting with init itself (always pid 1) and including long-lived daemons such as syslogd, klogd, and portmap; pseudo processes that are actually run in the kernel (mostly [k*] process names); and getty proceses listening on VTs that never get logins.

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#4 lore raw
In reply to Ray Olszewski

definitely higher then 2^16, I've got a process with the PID of 69917 I would guess MAX_INT which is 2^32 -1 = 4294967295

----- Original Message -----
From: "Ray Olszewski" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 11:58 AM
Subject: Re: About PID...???!!!

Quoted 2 lines
Quoted 1 line · John T. Williams

They are assigned linearly, however once a pid is used, it is never

reused

Quoted 7 lines
Quoted 1 line

until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think* at 32767 (or maybe 65535). Next time around, the kernel skips over any pids that are still in use from the last round of assignment.

Quoted 1 line

A pid of 413 means that when that process was fork()'ed there had been

412

Quoted 1 line
Quoted 1 line

other processes already created. But remember every time you type ls,

you've

Quoted 3 lines
Quoted 3 lines

run a process.

413 isn't a large pid at all. My linux box which I very rarely reboot is

at

Quoted 3 lines
Quoted 3 lines

PIDs that start at 20000

I'm surprised that any program you start after the boot process is as low

as

Quoted 3 lines
Quoted 1 line

412.

Whether that is surprising or not depends on what he uses the host for

and,

Quoted 12 lines

naturally, on how recently it was rebooted. While my workstation is way up there (30180), my Linux-based router, which does not start new processes very much, is only at pid 828.

And, of course, there are persistent processes on any Linux host that go back to the boot/init process ... starting with init itself (always pid 1) and including long-lived daemons such as syslogd, klogd, and portmap; pseudo processes that are actually run in the kernel (mostly [k*] process names); and getty proceses listening on VTs that never get logins.

Quoted 5 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#5 lore raw
Quoted 2 lines · John T. Williams

definitely higher then 2^16, I've got a process with the PID of 69917 I would guess MAX_INT which is 2^32 -1 = 4294967295

Actually, as it turns out, the right answer is "it depends".

Checking my kernel source, I find that the kernel's fork() routine checks against PID_MAX before wrapping. This value is defined, at least for 2.4.19, in <kernel_source_path>/include/linux/threads.h . My (Debian) kernel source has there

        #define PID_MAX 0x8000

which matches my observed wrapping at (or near) 32768 . You might see if your kernel source sets this value higher.

Quoted 7 lines

----- Original Message -----
From: "Ray Olszewski" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 11:58 AM
Subject: Re: About PID...???!!!

Quoted 8 lines
Quoted 2 lines
Quoted 1 line · John T. Williams

They are assigned linearly, however once a pid is used, it is never

reused

Quoted 5 lines
Quoted 1 line

until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think* at 32767 (or maybe 65535). Next time around, the kernel skips over any pids that are still in use from the last round of assignment.

[...]

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#6 lore raw
In reply to John T. Williams

Alright Alright, I concede it does loop, I should have used the word never. I'll change it to rarely and be done with it, in any case I think Silambu got his answer which briefly is:

No PID = 412 doesn't mean there are 412 process currently running on your machine.
Read the man page for ps to learn how to identify processes that are currently running.

----- Original Message -----
From: "John T. Williams" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 2:04 PM
Subject: Re: About PID...???!!!

Quoted 10 lines

definitely higher then 2^16, I've got a process with the PID of 69917 I would guess MAX_INT which is 2^32 -1 = 4294967295

----- Original Message -----
From: "Ray Olszewski" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 11:58 AM
Subject: Re: About PID...???!!!

Quoted 6 lines
Quoted 2 lines
Quoted 1 line · John T. Williams

They are assigned linearly, however once a pid is used, it is never

reused

Quoted 3 lines
Quoted 1 line

until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think*

at

Quoted 10 lines
Quoted 4 lines

32767 (or maybe 65535). Next time around, the kernel skips over any pids that are still in use from the last round of assignment.

Quoted 1 line

A pid of 413 means that when that process was fork()'ed there had been

412

Quoted 1 line
Quoted 1 line

other processes already created. But remember every time you type ls,

you've

Quoted 3 lines
Quoted 3 lines

run a process.

413 isn't a large pid at all. My linux box which I very rarely reboot

is

Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines

PIDs that start at 20000

I'm surprised that any program you start after the boot process is as

low

Quoted 6 lines

as

Quoted 3 lines
Quoted 1 line

412.

Whether that is surprising or not depends on what he uses the host for

and,

Quoted 1 line

naturally, on how recently it was rebooted. While my workstation is way

up

Quoted 5 lines
Quoted 5 lines

there (30180), my Linux-based router, which does not start new processes very much, is only at pid 828.

And, of course, there are persistent processes on any Linux host that go back to the boot/init process ... starting with init itself (always pid

1)

Quoted 2 lines
Quoted 2 lines

and including long-lived daemons such as syslogd, klogd, and portmap; pseudo processes that are actually run in the kernel (mostly [k*]

process

Quoted 6 lines
Quoted 6 lines

names); and getty proceses listening on VTs that never get logins.

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie"

in

Quoted 9 lines
Quoted 3 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

#7 lore raw

should not have used
----- Original Message -----
From: "John T. Williams" <[email protected]>
To: "John T. Williams" <[email protected]>; <[email protected]>
Sent: Wednesday, September 10, 2003 3:15 PM
Subject: Re: About PID...???!!!

Quoted 1 line

Alright Alright, I concede it does loop, I should have used the word

never.

Quoted 25 lines

I'll change it to rarely and be done with it, in any case I think Silambu got his answer which briefly is:

No PID = 412 doesn't mean there are 412 process currently running on your machine.
Read the man page for ps to learn how to identify processes that are currently running.

----- Original Message -----
From: "John T. Williams" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 2:04 PM
Subject: Re: About PID...???!!!

Quoted 10 lines

definitely higher then 2^16, I've got a process with the PID of 69917 I would guess MAX_INT which is 2^32 -1 = 4294967295

----- Original Message -----
From: "Ray Olszewski" <[email protected]>
To: <[email protected]>
Sent: Wednesday, September 10, 2003 11:58 AM
Subject: Re: About PID...???!!!

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Quoted 1 line · John T. Williams

They are assigned linearly, however once a pid is used, it is never

reused

Quoted 3 lines
Quoted 1 line

until the machine reboots.

This is not quite correct. The pid assignment process wraps, I *think*

at

Quoted 1 line
Quoted 1 line

32767 (or maybe 65535). Next time around, the kernel skips over any

pids

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

that are still in use from the last round of assignment.

Quoted 1 line

A pid of 413 means that when that process was fork()'ed there had

been

Quoted 5 lines
Quoted 5 lines

412

Quoted 1 line
Quoted 1 line

other processes already created. But remember every time you type ls,

you've

Quoted 2 lines
Quoted 2 lines

run a process.

Quoted 13 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

413 isn't a large pid at all. My linux box which I very rarely reboot

is

Quoted 4 lines

at

Quoted 3 lines
Quoted 3 lines

PIDs that start at 20000

I'm surprised that any program you start after the boot process is as

low

Quoted 6 lines

as

Quoted 3 lines
Quoted 1 line

412.

Whether that is surprising or not depends on what he uses the host for

and,

Quoted 1 line

naturally, on how recently it was rebooted. While my workstation is

way

Quoted 2 lines

up

Quoted 1 line
Quoted 1 line

there (30180), my Linux-based router, which does not start new

processes

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

very much, is only at pid 828.

And, of course, there are persistent processes on any Linux host that

go

Quoted 1 line
Quoted 1 line
Quoted 1 line

back to the boot/init process ... starting with init itself (always

pid

Quoted 10 lines

1)

Quoted 2 lines
Quoted 2 lines

and including long-lived daemons such as syslogd, klogd, and portmap; pseudo processes that are actually run in the kernel (mostly [k*]

process

Quoted 6 lines
Quoted 6 lines

names); and getty proceses listening on VTs that never get logins.

-
To unsubscribe from this list: send the line "unsubscribe

linux-newbie"

Quoted 7 lines

in

Quoted 6 lines
Quoted 3 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie"

in

Quoted 9 lines
Quoted 3 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs