Читайте также: |
|
MANAGEMENT PROCESSES
Purpose of
1.1 To study the processes in FreeBSD.
1.2 Become familiar with the process.
1.3 Implement management processes.
Key provisions
2.1 Process control: general
The process is a separate thread of execution or a single stream of instructions a computer. The process - an information context, having a single address space and consists typically of three segments - Package (includes instructions (program) management processor), data and stack. Each process runs in its own virtual address space. Appeal to the real address space is possible only at the kernel level. Process control functions as the nucleus, called a virtual machine (VM). Prior to the life of his data and code stored in a file called an executable. In addition to static data on the stage of execution of the OS process provides additional data, such as a table of file handles, environment variables, dynamically allocated memory.
Start the process can be just another process. It creates a hierarchy of processes. The first process, having no parent process is init, which starts at boot time operating system.
Each UNIX process assigns the control terminal, which are associated to three standard devices: input, output and error output.
Among the user processes in UNIX are allocated, so-called daemon processes. These are processes that can be performed throughout the operating system. Such processes should have as a parent init process and do not have a controlling terminal.
It may seem that, in UNIX everything is done simultaneously, but in reality, in a unit time runs only one process. The illusion of parallel execution method creates a "time-quantizing", whereby the system at regular intervals alter the current running process.
The system administrator can monitor the status of the process, to manage the allocation of CPU time each process, pause and forcibly terminates the process.
As mentioned above, each process consists of the address space and a set of data structures contained in the nucleus of the system. The most important data in the structures include:
- table of memory allocation process;
- current status of the process;
- priority of the process;
- resource information system used by the process;
- process owner.
Each new process is assigned a unique number PID. Actual value of PID does not play a big role, it is assigned the kernel simply in order, starting with 0 and till 65535. When the number ends, the kernel re-starts at 0, passing still exist in the PID.
The new process in UNIX is created by cloning an existing process, after which the text (i.e., a set of instructions for the processor) the new process replaced with a program that process should execute. The UNIX source process is called the parent and its clone - generated by or a subsidiary.
In addition to its own identifier PID, each process has an attribute of its parent process - PPID.
Each process has a UID - User ID who created the process. Making changes to the process may only its creator and a privileged user (root). There is also a process EUID-the so-called "effective" UID. It is used to determine which resources a process has access rights. Typically, EUID and UID match. They differ for the programs in which the bit is changing the user ID (the so-called suid - program).
Similarly, GID - identification number of the person who created the process, EGID - "effective" GID. When the process is started, its GID is equal to the GID of the parent process. If the process tries to access a file that is not the owner permissions, the kernel checks to be whether to allow issued pursuant EGID.
The owner of the process is the owner of the parent. Accordingly, considered the right of access to the files. However, UNIX has mechanisms for change of ownership process. The first mechanism is implemented, for example, in process login. This process runs as root, but after a successful registration process runs the shell as the user. The second mechanism is based on specific bits of empowerment. If you have a bit of empowerment to the user (SUID) - the process does not comply with the human user who launched it, and with the owner of the file. For example, if the owner of the file is root and suid -bit set, the process executed with rights of superuser.
When a user enters a command, interpreter Shell is for your terminal manager process. This means that the interpreter is a process that accepts user input.
The very existence of the process does not give him the right to receive CPU time. The process can be in various states:
Waiting - waiting for the process of allocating a resource
Zombie process - When the process completes, it notifies its parent of approaching death. After receiving confirmation of its PID is removed from the process table. Zombie process - a process whose resources were fully released, but the completion of which has not been confirmed by his parents. Normally, if the parent is no longer in the system, interferes with the process of init. But sometimes it does not.
Swapped - the process is in the swap-partition on the disk.
Stopped - process suspended. Workable process has received all necessary resources and is just waiting for the allocation of CPU time for data processing.
Waiting process is waiting for a certain event. For example, the command interpreter waits for user commands from the keyboard and spends in a waiting state most of his time.
Swapped process does not exist in memory. It is written in swap -section on the disc and wait "for the hour."
From time to time appear in the system processes, one way or another require administrator intervention. The main types of such processes - depended and unmanaged processes.
Crashed processes do not do anything, do not meet its controlling terminal, and just "hang", taking up system resources. Unmanaged processes are of two types - user and system. Unmanaged user process does not necessarily work correctly. All he can "eat" a lot of system resources, and because it would be idle others may not be less than helpful processes.
Unmanaged system process may simply unpredictable effect on system performance.
Kill command
For process control system provides a team kill.
The format of the command: kill <-signal> pid, where <signal> - a number or symbolic name sent by the process signal. Kill command is most often used for terminating the process. The most commonly used signals:
- 9 (KILL) - assured destruction process;
- 15 (TERM) - completion of the program;
- 1 (HUP) - all clear signal. Many system processes upon receipt of this signal re-read its configuration files. It is recommended to give the signal before sending a HUP signal kill.
Sometimes, though rarely, processes fall into such a state that they can not "kill" even issuing the command kill -9pid.
In this case, the most effective way to "kill" the process - the command reboot.
2.3 Priorities processes. Nice command
On the priority of the process depends on how much CPU time it receives. Choosing to perform the process, the kernel is a process with the highest "domestic priority." Just change the value of domestic priority is impossible, but you can influence it by changing the so-called nice -value.
For this purpose, the command nice is used. The format of this command:
nice <The relative priority of the process - parent> <command>. The relative priority of a FreeBSD system is in the range from -20 to +20.
It is important to remember: The lower the nice - the higher the priority of the process.
Example:
# nice -10 / usr / local / mygame
If the user does not take special measures, the new process inherits the priority of its parent. You can increase the value of nice (i.e. lower priority), but can not reduce it, even for the return process to the priority obtained at "birth".
A privileged user can change the priorities of the processes as you wish, up to the fact that all processes will not work because of one single.
In the system, FreeBSD is the command renice, through which you can change the priority already running process. Its format is:
renice <priority> [-p pid] [-g <group>] [-u <user>]
Example:
# renice +1 -p 989 -u daemon root -p 32
The sample is reduced by 1 priority processes with PID numbers 989 and 32, as well as all processes owned by daemon and root. The current process control, commands ps and top.
2.4 Ps command
For the current control of processes in the system, the command ps.
If she entered without options, it will show only your own user processes and the processes of exchange with the terminal. The team has options:
- a - gives information on all user processes;
- s - shows the values of environment variables;
- h - for output to PAGER (more or less) displays the title of listing;
- m - sort output by memory usage;
- r - sorts the output by use of CPU time;
- x - output is not associated with the terminals (ie, appear as such, and a daemon process).
Dial command
# ps -ax
Let's look at listing (shown here for brevity, only one line header and only a portion of the fields):
USER PID STAT START TIME COMMAND
bob 1167 R + 5:57 PM 0:00.04 ps-ax
USER - name of the owner of the
PID - process ID
STAT - the current status of the process
R = workable, or ready to do,
T = suspended
I = inactive (BSD), an intermediate state (System V),
S = (waiting> 20 sec)
Z = zombie process
Additional Flags:
W = process svopirovan
+ = Process priority mode, the terminal
START - start time of
TIME - CPU time consumed by the process
COMMAND - command name and arguments. The output of this command is similar to that command ps.
Дата добавления: 2015-11-14; просмотров: 50 | Нарушение авторских прав
<== предыдущая страница | | | следующая страница ==> |
Роль транснациональных корпораций (ТНК) и транснациональных банков (ТНБ) в мировом хозяйстве | | | Standard streams |