Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

stime & utime: Time that a process has been scheduled Information in kernel/user

ID: 3797302 • Letter: S

Question

stime & utime: Time that a process has been scheduled Information in kernel/user mode

Using bash

Using the files stored at /proc write a program/script to find information about a specific process using a user provided pid. In the following, you will find a list of the task struct members for which you are required to find their value. In the task struct a lot of the data you are finding is not represented as member values but instead pointers to other linux data structures that contain these members. All of the information you will be retrieving can be found in a processs proc directory (/proc/Ipid). Your program must be able to retrieve the following data about any given process if the given process Id is existing under direcotry /proc Table #1: Process Attributes Category Required Variables Items Description Identifiers ID, PPID Process ID of the current process and its parent EUID, EGID Effective user and group ID RUID, RGID Real user and group ID FSUID, FSGID File system user and group ID State R, S, D, T. Z. X Running, Sleeping, Disk sleeping, Stopped, Zombie, and Dead Thread IDs of a process Information Priority Priority Number Integer value from 1 to 99 for real time processes Integer value from -20 to 19 Niceness Value Time that a process has been scheduled Time stime & ultime Information in kernel user mode Time that a process has waited on children cstime & cutime being run in kernel /user mode

Explanation / Answer

root@ctas-desktop:~# cat p.sh
echo "Enter the process ID to get the details of that process"
read a

echo "Here is the values requested for the Process ID $a"
cat /proc/$a/status
echo "


NOTE................

The fields are as follows:

Name: Command run by this process.

State: Current state of the process. One of R running, S sleeping, D disk sleep, T stopped, T tracing stop, Z zombie, or
X dead.

Tgid: Thread group ID i.e., Process ID.

Pid: Thread ID see gettid2.

PPid: PID of parent process.

TracerPid: PID of process tracing this process 0 if not being traced.

Uid, Gid: Real, effective, saved set, and filesystem UIDs GIDs.

FDSize: Number of file descriptor slots currently allocated.

Groups: Supplementary group list.

VmPeak: Peak virtual memory size.

VmSize: Virtual memory size.

VmLck: Locked memory size see mlock3.

VmHWM: Peak resident set size high water mark.

VmRSS: Resident set size.

VmData, VmStk, VmExe: Size of data, stack, and text segments.

VmLib: Shared library code size.

VmPTE: Page table entries size since Linux 2.6.10.
Threads: Number of threads in process containing this thread.

SigQ: This field contains two slash-separated numbers that relate to queued signals for the real user ID of this process. The first of these is
the number of currently queued signals for this real user ID, and the second is the resource limit on the number of queued signals for this process
see the description of RLIMIT_SIGPENDING in getrlimit2.

SigPnd, ShdPnd: Number of signals pending for thread and for process as a whole see pthreads7 and signal7.

SigBlk, SigIgn, SigCgt: Masks indicating signals being blocked, ignored, and caught see signal7.

CapInh, CapPrm, CapEff: Masks of capabilities enabled in inheritable, permitted, and effective sets see capabilities7.

CapBnd: Capability Bounding set since kernel 2.6.26, see capabilities7.

Cpus_allowed: Mask of CPUs on which this process may run since Linux 2.6.24, see cpuset7.

Cpus_allowed_list: Same as previous, but in list format since Linux 2.6.26, see cpuset7.

Mems_allowed: Mask of memory nodes allowed to this process since Linux 2.6.24, see cpuset7.

Mems_allowed_list: Same as previous, but in list format since Linux 2.6.26, see cpuset7.

voluntary_context_switches, nonvoluntary_context_switches: Number of voluntary and involuntary context switches since Linux 2.6.23.


"

root@ctas-desktop:~# vi p.sh
root@ctas-desktop:~# sh p.sh
Enter the process ID to get the details of that process
2178
Here is the values requested for the Process ID 2178
Name: bash
State: S (sleeping)
Tgid: 2178
Ngid: 0
Pid: 2178
PPid: 2174
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 256
Groups: 0
VmPeak: 27028 kB
VmSize: 27028 kB
VmLck: 0 kB
VmPin: 0 kB
VmHWM: 5544 kB
VmRSS: 5544 kB
VmData: 2136 kB
VmStk: 136 kB
VmExe: 956 kB
VmLib: 2280 kB
VmPTE: 76 kB
VmSwap: 0 kB
Threads: 1
SigQ: 1/3732
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000010000
SigIgn: 0000000000380004
SigCgt: 000000004b817efb
CapInh: 0000000000000000
CapPrm: 0000003fffffffff
CapEff: 0000003fffffffff
CapBnd: 0000003fffffffff
Seccomp: 0
Cpus_allowed: f
Cpus_allowed_list: 0-3
Mems_allowed: 00000000,00000001
Mems_allowed_list: 0
voluntary_ctxt_switches: 213
nonvoluntary_ctxt_switches: 190

NOTE................

The fields are as follows:

Name: Command run by this process.

State: Current state of the process. One of R running, S sleeping, D disk sleep, T stopped, T tracing stop, Z zombie, or
X dead.

Tgid: Thread group ID i.e., Process ID.

Pid: Thread ID see gettid2.

PPid: PID of parent process.

TracerPid: PID of process tracing this process 0 if not being traced.

Uid, Gid: Real, effective, saved set, and filesystem UIDs GIDs.

FDSize: Number of file descriptor slots currently allocated.

Groups: Supplementary group list.

VmPeak: Peak virtual memory size.

VmSize: Virtual memory size.

VmLck: Locked memory size see mlock3.

VmHWM: Peak resident set size high water mark.

VmRSS: Resident set size.

VmData, VmStk, VmExe: Size of data, stack, and text segments.

VmLib: Shared library code size.

VmPTE: Page table entries size since Linux 2.6.10.
Threads: Number of threads in process containing this thread.

SigQ: This field contains two slash-separated numbers that relate to queued signals for the real user ID of this process. The first of these is
the number of currently queued signals for this real user ID, and the second is the resource limit on the number of queued signals for this process
see the description of RLIMIT_SIGPENDING in getrlimit2.

SigPnd, ShdPnd: Number of signals pending for thread and for process as a whole see pthreads7 and signal7.

SigBlk, SigIgn, SigCgt: Masks indicating signals being blocked, ignored, and caught see signal7.

CapInh, CapPrm, CapEff: Masks of capabilities enabled in inheritable, permitted, and effective sets see capabilities7.

CapBnd: Capability Bounding set since kernel 2.6.26, see capabilities7.

Cpus_allowed: Mask of CPUs on which this process may run since Linux 2.6.24, see cpuset7.

Cpus_allowed_list: Same as previous, but in list format since Linux 2.6.26, see cpuset7.

Mems_allowed: Mask of memory nodes allowed to this process since Linux 2.6.24, see cpuset7.

Mems_allowed_list: Same as previous, but in list format since Linux 2.6.26, see cpuset7.

voluntary_context_switches, nonvoluntary_context_switches: Number of voluntary and involuntary context switches since Linux 2.6.23.