[torquedev] job vs. session

David Singleton David.Singleton at anu.edu.au
Tue Aug 1 16:16:16 MDT 2006


A session is a Unix/Linux concept of a collection of processes
usually for the purpose of associating those processes with
a tty, eg. login session.  The session id of a process is set
to its process id by calling setsid().  Children of that process
will inherit that session id.  Run ps -ej to see the PID, PGID
and SID of all processes.

A PBS job is made up of tasks which are also just collections of
processes. The MOM initially spawns one task (a shell) which runs
the job batch script.  That batch script (through calls to the PBS
tm API inside mpiexec or pbsdsh commands etc) may request MOMs to
spawn other tasks as part of the PBS job.

PBS would like to believe that each task in a PBS job has a
session id associated with it.  Certainly the MOM calls setsid()
as it initializes each task so they do start with a unique session
id.  For the purposes of resource monitoring and signalling, the
MOM uses the session id of a process to decide if the process is
part of a job task or not. (The MOM walks the whole process tree
on a host to track jobs.)

But since any process can call setsid() at any time (with some
restrictions), this tracking method is fallable.  After calling
setsid(), a process has effectively "escaped" from MOM.  Ideally
within the kernel each process would also have a JID ("jobid") that
can only be set by a privileged user (like MOM) and inherited by all
children.

David

Diwaker Gupta wrote:
> Hi all,
> 
> Exactly what is the difference between a job and a session? I couldn't
> find any concrete documentation on them. I'm more interested in an
> implementation oriented definition -- for Linux, it seems like jobs
> are executed within processes, and sessions are denoted by PIDs. So
> are sessions simply the execution containers of jobs? Can there be
> multiple jobs per session or vice-versa?
> 


More information about the torquedev mailing list