Skip to contentSkip to conversation

How can I know the number of current users in the system?

DISCUSSION Wei Xiaoliang 5 participants 5 messages Nov 5, 2001 – Nov 6, 2001

lore
Share & tools
lore
#0 lore raw

Hi every one,
I have a problem not clear: Is there any counter for the user number
in linux?
I want to do anexperiment which will get the number of current user in the system and try fair-share scheduling based on it. I read the sys.c and user.c but cannot find a counter for it. Is there any counter for this things?

If no, where can I put the inc instruct and dec instruct or the
counter? in the uid_hash_insert and uid_hash_remove?
Thank you!
-----------------------------------------------------------------------
Xiaoliang (David) Wei Graduate Student in CS, Caltech
E-mail: [email protected] Office: 158 Jorgensen
Phone: 1-(626)-395-3555 (O) 1-(626)-577-5238 (H)
Mail: Xiaoliang Wei, 256-80 Caltech, Pasadena, CA 91125, U.S.A.
WWW: http://www.cs.caltech.edu/~weixl http://166.111.69.241/~wxl
-----------------------------------------------------------------------

#1 lore raw

Hi Wei.

Quoted 7 lines

I have a problem not clear: Is there any counter for the user number in linux?

I want to do anexperiment which will get the number of current user in the system and try fair-share scheduling based on it. I read the sys.c and user.c but cannot find a counter for it. Is there any counter for this things?

Here's a simple shell command to provide that information:

who | wc -l

Try it and see...

Best wishes from Riley.

#2 lore raw
Quoted 5 lines · Riley Williams

Here's a simple shell command to provide that information:

who | wc -l

Try it and see...

Actually that's not a fair count of the number of users on the box, only the number that are *logged in*. On one of our boxes at work, that would miss about 80% of the users, maybe more. Anyone that RSH's or SSH's in without a tty wouldn't be counted:

cabbey@CHESIRE ~> ssh -T tweedle who
cabbey@CHESIRE ~>

so even though I was executing who on tweedle it didn't see me logged in. A more realistic situation:

[cabbey@tweedle cabbey]$ who

cabbey   pts/0    Nov  5 19:05
cabbey   pts/1    Nov  5 19:05

[cabbey@tweedle cabbey]$

pts/0 is my pine session, pts/1 is the shell I executed who in, there are also two copies of "xeyes" running back to chesire that were started as 'ssh -T tweedle /usr/X11r6/bin/xeyes -display chesire:0' but don't appear in who

going back to running it remotely:

cabbey@CHESIRE ~> ssh -T tweedle who

cabbey   pts/0    Nov  5 19:05
cabbey   pts/1    Nov  5 19:05

cabbey@CHESIRE ~>

If those were move cpu hungry programs than xeyes, like vncserver with a complete kde/gnome desktop running under it then you could really be missing some data from a scheduling pov... which as I recall was what the original poster wanted to fiddle with.

Signature · 2 lines
now the forces of openness have a powerful and
  unexpected new ally - http://ibm.com/linux
#3 lore raw
In reply to Wei Xiaoliang

The short answer is; No.

The slightly longer answer is that Linux/Unix kernels don't have a consept of a logged in user. userids are used for really only one thing, owner ship of data. In order to do enforce it a process must be running as a spesific user. Once programs had a userid attached to it, things rolled on from there. However there is no way of figuring out if a process is "online" or something else.

However, the big iron *ix'es do this, and I can't remember exactly how they do it. But another feature often pop up; guaranteeing a users a minimum CPU percentage. (Even if I hate it, it has merit for RT/responce critical apps.)

My suggestion is to loop thru the processes and collect a list of all the userids and form a tree/list of all the processes belonging to each of them. Then you fair share schedule between the users.

Another issue: did you want to serialize scheduling? (run all the processes for a user in sequence before starting on the next user?) Another feature on the "big" *ix'es.

THis is going to have some side effects! nicing a process up or down may only nice relative to the users other processes, not other users. It may be what you want, just thought I'd bring it up.

Next issue, do you want to fair share between root and the other users? (and THAT is a time old discussion...)

TJ

søn, 2001-11-04 kl. 23:15 skrev Wei Xiaoliang:

Quoted 23 lines

Hi every one,
I have a problem not clear: Is there any counter for the user number
in linux?
I want to do anexperiment which will get the number of current user in the system and try fair-share scheduling based on it. I read the sys.c and user.c but cannot find a counter for it. Is there any counter for this things?

If no, where can I put the inc instruct and dec instruct or the
counter? in the uid_hash_insert and uid_hash_remove?
Thank you!
-----------------------------------------------------------------------
Xiaoliang (David) Wei Graduate Student in CS, Caltech
E-mail: [email protected] Office: 158 Jorgensen
Phone: 1-(626)-395-3555 (O) 1-(626)-577-5238 (H)
Mail: Xiaoliang Wei, 256-80 Caltech, Pasadena, CA 91125, U.S.A.
WWW: http://www.cs.caltech.edu/~weixl http://166.111.69.241/~wxl
-----------------------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" 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.tux.org/lkml/

Signature · 10 lines
_________________________________________________________________________

Terje Eggestad                  [email protected]
Scali Scalable Linux Systems    http://www.scali.com

Olaf Helsets Vei 6              tel:    +47 22 62 89 61 (OFFICE)
P.O.Box 70 Bogerud                      +47 975 31 574  (MOBILE)
N-0621 Oslo                     fax:    +47 22 62 89 51
NORWAY            
_________________________________________________________________________
#4 lore raw
In reply to Wei Xiaoliang
Quoted 4 lines · Terje Eggestad

My suggestion is to loop thru the processes and collect a list of all the userids and form a tree/list of all the processes belonging to each of them. Then you fair share schedule between the users.

Hmmm, you should be able to count the number of pty's and tty's. Every logged in user is attached to some sort of getty whose parent is the init task (1). That might be a basis for a count.

Signature · 5 lines
------------------------------------------------------
    Nuke bin Laden:           Dale Amon, CEO/MD
  improve the global          Islandone Society
     gene pool.               www.islandone.org
------------------------------------------------------