Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of creating the android process

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the android process creation method is what the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this android process creation method is what the article will have a harvest, let's take a look.

Process refers to the running program, the smallest unit of resource allocation. You can view the running process through commands such as "ps" or "top". Thread is the minimum scheduling unit of the system. A process can have multiple threads, and threads in the same process can share the same resources of this process. The code for this chapter is in the process/ directory.

Process type:

1. Interactive process: started by shell, users and computers for question-and-answer process.

two。 Batch process: a process that submits tasks to a waiting queue for sequential execution without being associated with a specific terminal.

3. Daemon: a special process running in the background with which users cannot talk.

Three states of the process:

1. Running state, running or waiting in the run queue.

two。 Interruptible waiting state, dormant, waiting for the resource to be applied for or waiting for interruption, the signal wakes up.

3. Uninterruptible waiting state, dormant waiting resources are valid and cannot be awakened by interruptions or signals.

4. In the terminated state, the process is stopped or tracked, and when a SIGCONT signal is received, it will resume the running state.

5. In zombie state, the process stops running for some reason, but the process descriptor still exists and cannot be Kill.

If you want to destroy a process, type "ps-elf" in the terminal to view the process number, as shown in figure 66.2:

If you want to destroy the qtcreator process, you can destroy it using "kill-9 3001"

1 process creation

All processes are created by other processes (except the idle process with pid number 0). The init process with pid number 1 is the first process to run after the system starts and is the parent process of all processes. The init process initializes part of the system services and creates other processes.

The process that creates the new process is called the parent process, and the new process is called the child process. The parent process and the child process have the same code segment data segment and have their own independent address space. Using the write-time copy technology, that is, the new process created will not immediately copy the resource space of the parent process, but will copy the resources only when it is modified. In addition, the signals and file locks suspended by the parent process will not be inherited by the child process.

After the child process ends, its parent process will reclaim its resources, otherwise it will become a zombie process.

If the parent process ends first, the child process will be adopted by the init process, called the orphan process.

The terminal enters "ps-el" to view the process status. PID is the process number, and PPID is the parent process number of this process. As shown in figure 1.1, the parent process of process 1505 is 1366 process.

Getpid (): get the process PID

The return value is the PID number.

Fork (): system call to create a process

# include

Pid_t fork (void)

Calling the parent process successfully returns the child process number, the child process returns 0, and the failure returns-1.

Such as the following code:

For.c:

Print the results:

During the execution of the program, the fork () process 2531 is called for the first time to create the child process 2532; the second time fork (), the process 2531 creates the child process 2533, and the process 2532 creates 2534, as shown in figure 1.3:

This is the end of the article on "what is the method of creating an android process?" Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "what is the method of creating the android process". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report