Chapter 4 Process Control

Ace your homework & exams now with Quizwiz!

UID

A process's UID is the user identification number of the person who created it, or more accurately, it is a copy of the UID value of the parent process. Usually, only the creator (aka, the owner) and the superuser can manipulate a process.

nice

A process's niceness can be set at the time of creation with the nice command and adjusted later with the renice command. nice takes a command line as an argument, and renice takes a PID or (sometimes) a username.

Niceness

A process's scheduling priority determines how much CPU time it receives.

Each of the time-related fields can contain

A star, which matches everything A single integer, which matches exactly Two integers separated by a dash, matching a range of values A range followed by a slash and a step value, e.g., 1-10/2 A comma-separated list of integers or ranges, matching any value

ps lax

Shown here in an abbreviated example, ps lax includes fields such as the parent process ID (PPID), niceness (NI), and the type of resource on which the process is waiting (WCHAN, short for "wait channel").

Signals Signals are process-level interrupt requests. About thirty different kinds are defined, and they're used in a variety of ways:

They can be sent among processes as a means of communication. They can be sent by the terminal driver to kill, interrupt, or suspend processes when keys such as <Control-C> and <Control-Z> are pressed. They can be sent by an administrator (with kill) to achieve various ends. They can be sent by the kernel when a process commits an infraction such as division by zero. They can be sent by the kernel to notify a process of an "interesting" condition such as the death of a child process or the availability of data on an I/O channel.

Common uses for scheduled tasks

Sending mail Cleaning up a filesystem Rotating a log file Running batch jobs Backing up and mirroring

PPID: parent PID

When a process is cloned, the original process is referred to as the parent, and the copy is called the child. The PPID attribute of a process is the PID of the parent from which it was cloned, at least initially. (If the original parent dies, init or systemd becomes the new parent.

The kernel's internal data structures record various pieces of information about each process. Here are some of the more important of these:

The process's address space map The current status of the process (sleeping, stopped, runnable, etc.) The execution priority of the process Information about the resources the process has used (CPU, memory, etc.) Information about the files and network ports the process has opened The process's signal mask (a record of which signals are blocked) The owner of the process

For example, the time specification

means "10:45 a.m., Monday through Friday." A hint: never use stars in every field unless you want the command to be run every minute, which is useful only in testing scenarios. One minute is the finest granularity available to cron jobs.

thread

A "thread" is an execution context within a process. Every process has at least one thread, but some processes have many. Each thread has its own stack and CPU context but operates within the address space of its enclosing process.

Time ranges in crontabs can include a step value.

For example, the series 0,3,6,9,12,15,18 can be written more concisely as 0-18/3.

The signals KILL, INT, TERM, HUP, and QUIT all sound as if they mean approximately the same thing, but their uses are actually quite different. It's unfortunate that such vague terminology was selected for them. Here's a decoding guide:

KILL is unblockable and terminates a process at the kernel level. A process can never actually receive or handle this signal. INT is sent by the terminal driver when the user presses <Control-C>. It's a request to terminate the current operation. Simple programs should quit (if they catch the signal) or simply allow themselves to be killed, which is the default if the signal is not caught. Programs that have interactive command lines (such as shells) should stop what they're doing, clean up, and wait for user input again. TERM is a request to terminate execution completely. It's expected that the receiving process will clean up its state and exit. HUP has two common interpretations. First, it's understood as a reset request by many daemons. If a daemon is capable of rereading its configuration file and adjusting to changes without restarting, a HUP can generally trigger this behavior.

strace

Linux command used to view system calls accessed during the execution of a command

The kernel assigns a unique ID number to every process.

Most commands and system calls that manipulate processes require you to specify a PID to identify the target of the operation. PIDs are assigned in order as processes are created.

Pages

Pages are the units in which memory is managed. They are usually 4KiB or 8KiB in size.

EUID

The EUID is the "effective" user ID, an extra UID that determines what resources and files a process has permission to access at any given moment. For most processes, the UID and EUID are the same, the usual exception being programs that are setuid.

GID and EGID: real and effective group ID

The GID is the group identification number of a process. The EGID is related to the GID in the same way that the EUID is related to the UID in that it can be "upgraded" by the execution of a setgid program. As with the saved UID, the kernel maintains a saved GID for each process.

ps command

The command used to obtain information about processes currently running on the system.

cron

The cron daemon is the traditional tool for running commands on a predetermined schedule. It starts when the system boots and runs as long as the system is up. There are multiple implementations of cron, but fortunately for administrators, the syntax and functionality of the various versions is nearly identical.

Transient timers

You can use the systemd-run command to schedule the execution of a command according to any of the normal systemd timer types, but without creating task-specific timer and service unit files. For example, to pull a Git repository every ten minutes:

ps aux

displays all processes running on your terminal with user names

top

top is a sort of real-time version of ps that gives a regularly updated, interactive summary of processes and their resource usage. For example:

saved UID

which is a copy of the process's EUID at the point at which the process first begins to execute.


Related study sets

HBS 3.2.2 Pancreas, liver and gall bladder

View Set

Signs, Pavement Markings, and Signals

View Set

coral reef ecology final OCE4265

View Set

Unit 2: Tableau Desktop Specialist Exam

View Set

Comptia Security+ - Chapter 4 Quiz - Securing Your Network

View Set

research methods final semester 2

View Set