Chapter III Reading notes

Source: Internet
Author: User

Chapter III Process Management of reading notes--Overview of the process

Process : A program on a computer a running activity on a data set is the basic unit of the system's resource allocation and dispatch, and is the basis of the operating system structure.

In the early process design-oriented computer architecture, the process is the basic execution entity of the program, and in the contemporary thread-oriented computer architecture, the process is the container of the thread. A program is a description of instructions, data, and its organization, and the process is the entity of the program.

process creation : Using the wrapper function fork (), Exit is launched with wait () recovery.

Process Descriptor:task_struct structure (PCB)

Definition: In order to manage processes, the operating system must clearly describe what each process does, and for this reason, the operating system uses data structures to represent the processing of different entities, which are commonly referred to as process descriptors or process control blocks, and in a Linux system it contains all the information about the process. The operating system can track information about this structure at any time.

CPU task corresponding structure is: allocation process pcb--storage space--record current data and status--record context---Index all child parent relationships-wait for return or end

Basic steps for process creation to recycling:

1 in a Linux system, the fork () system call is usually called, and the system call creates a completely new process by copying an existing process. The process called fork () is called the parent process, and the newly generated process is called a child process. At the end of the call, at the same location as the return point, the parent process resumes execution and the child process begins execution. The fork () system call returns two times from the kernel: one at a time back to the parent process, and the other to the newly born child process.

2 Typically, a new process is created to execute a new, different program immediately, and then call exec* () to create a new address space and load the new program. In the modern Linux kernel, fork () is actually implemented by the clone () system call.

3 Finally, the program exits execution via the exit () system call. This function will terminate the process and release the resources it consumes. The parent process can query whether the child process is terminated through the WAIT4 () system call, which in fact gives the process the ability to wait for a particular process to finish executing. After the process exits execution, it is set to a zombie state until its parent process calls wait () or waitpid ().

Threads---Smaller units of execution

Threads: A single sequential control process in a program. A relatively independent, scheduled execution unit within a process is the unit of dispatch for the system to dispatch and dispatch CPUs independently of the operating program.

Characteristics:

1 Lightweight Entity-----Consumes only the necessary resources

2 Unit of Independent Dispatch and dispatch

3 can be executed concurrently

4 Sharing Process Resources

Compare to process:

Address space and other resources (such as open files): Processes are independent of each other and shared among threads of the same process. Threads within a process are not visible in other processes.

Communication: Inter-process communication IPC, between threads can directly read and write process data segments (such as global variables) to communicate--requires process synchronization and mutual exclusion means of support to ensure data consistency.

Scheduling and switching: Thread context switches are much faster than process context switches.  In a multithreaded OS, a process is not an executable entity. Summary: One of the functions of the operating system is mainly to manage the processor. In order to improve the CPU utilization. Through process management to coordinate the relationship between the multi-channel program, so that the CPU is fully utilized. and set the process corresponding information to facilitate the CPU back and forth, and the specific process structure requires a certain amount of resources processing, that is, space change time

Chapter III Reading notes

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.