3. Explain process groups from the view of a kernel explorer. You may want to consult the man page for setpgid. Please reference code. The kernel keeps track of processes by associating them into groups. Each process group has a unique identifier, the GID or Group ID. Each GID for a group is determinded by the parnets PID. This proces is known as the session leader. There is a setpgrp() system call can be used to start a process and make it the group leader. The setpgid() can be used to add a process to a certain process group. The setpgrp can be used like this... #include #include pid_t setpgrp(void); int setpgid(pid_t pid, pid_t pgid); The system call was found in several part of the source code. It is definded in kernel/enrty.s.. .long SYMBOL_NAME(sys_setpgid) Then later in include/asm-i386/unistd.h: #define __NR_setpgid 57 and in kernel/sys.c there is an excellent example of how the kernel deals with processes and groups.... asmlinkage int sys_setpgid(pid_t pid, pid_t pgid) struct task_struct * p; int err = -EINVAL; if (!pid) pid = current->pid; if (!pgid) pgid = pid; if (pgid < 0) return -EINVAL; /* From this point forward we keep holding onto the tasklist lock * so that our parent does not change from under us. -DaveM */ read_lock(&tasklist_lock); err = -ESRCH; p = find_task_by_pid(pid); if (!p) goto out; if (p->p_pptr == current || p->p_opptr == current) { err = -EPERM; if (p->session != current->session) goto out; err = -EACCES; if (p->did_exec) goto out; } else if (p != current) goto out; err = -EPERM; if (p->leader) goto out; if (pgid != pid) { struct task_struct * tmp; for_each_task (tmp) { if (tmp->pgrp == pgid && tmp->session == current->session) goto ok_pgid; } goto out; } ok_pgid: p->pgrp = pgid; err = 0; out: /* All paths lead to here, thus we are safe. -DaveM */ read_unlock(&tasklist_lock); return err;