Linux process management and job control

Source: Internet
Author: User

Linux is a multitasking operating system that runs multiple processes at the same time, and one or more related processes being executed are called a job. With job control, users can run multiple jobs at the same time and switch between jobs when needed. This chapter details process management and job control commands, including starting processes, viewing processes, and scheduling jobs.

The concept of processes and operations

Linux is a multi-user multitasking operating system. Multiuser means that multiple users can use the computer system at the same time; multitasking means that Linux can perform several tasks at once, and it can perform another task when it has not yet completed a task.

The operating system manages multiple user requests and multiple tasks. Most systems have only one CPU and one main memory, but a system may have multiple level two storage disks and multiple input/output devices. The operating system manages these resources and shares resources among multiple users, creating a false impression when you make a request, as if the system were only occupied by you alone. In fact, the operating system monitors a queue of tasks that are waiting to be executed, including user jobs, operating system tasks, mail, and print jobs. The operating system assigns the appropriate time slices to each task based on the priority of each task, each of which has a a fraction second, which, although it looks short, is actually enough for the computer to complete thousands of instruction sets. Each task is run by the system for a period of time, then hangs, the system turns to other tasks, and then returns to the task after a period of time until a task is completed and removed from the task queue.

Everything that runs on a Linux system can be called a process. Each user task, each system Management daemon, can be called a process. Linux uses time-sharing management to make all tasks share system resources. When we talk about processes, we don't care about how these processes are distributed, or how the kernel manages to allocate time slices, and we care about how to control these processes so that they work well for the user.

A more formal definition of a process is a separate program that runs in its own virtual address space. Processes are different from programs, and processes are not programs, although they are generated by programs. The program is just a static set of instructions, which does not account for the running resources of the system, and the process is a dynamic, dynamically changing program that uses the system to run resources at any time. And a program can start multiple processes.

The Linux operating system consists of three different types of processes, each with its own characteristics and attributes.

Interaction process-a process initiated by a shell. The interaction process can be run either in the foreground or in the background.

Batch process-This process is not connected to a terminal and is a sequence of processes.

The monitoring process (also known as the daemon)--linux the process that started when the system started and runs in the background.

Each of these three processes has its own role, and the use of the occasion is also different.

There are also differences in the concepts of processes and jobs. An executing process is called a job, and the job can contain one or more processes, especially if the pipe and redirection commands are used. For example, the job "Nroff-man ps.1|grep kill|more" starts three processes at the same time.

Job control refers to the behavior of controlling a running process. For example, a user can suspend a process and wait a while before proceeding with the process. The shell records all of the initiated processes, and during each process, the user can suspend the process arbitrarily or restart the process. Job control is a feature of many shells, including bash and tcsh, that allow users to switch between multiple separate jobs.

Typically, a process is referred to as a job when it is associated with job control.

In most cases, the user runs only one job at a time, the command they finally type to the shell. However, with job control, users can run multiple jobs at the same time and switch between those jobs if needed. What is the use of this? For example, when a user edits a text file and needs to abort editing to do something else, with job control, the user can have the editor suspend and return to the shell prompt to do something else. When everything else is done, the user can restart the pending editor and return to where it was just aborted, as if the user had never left the editor. This is just one example, and there are many other practical uses for job control.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.