iOS Processes and Threads

Source: Internet
Author: User

Process:

The ongoing program is called the process, which is responsible for the memory allocation of the program running;

Each process has its own independent virtual memory space.

Threads: (Maximum 1M of stack space for the main thread, up to 512K of stack space per stripe)

The thread itself basically does not own system resources, only has a point in the operation of the necessary resources (such as program counters, a set of registers and stacks)

A thread is a separate execution path (control unit) in a process;

At least one thread is included in a process, that is, the main path;

Time-consuming execution paths (such as network requests) can be executed in other threads;

The thread cannot be killed, but it can pause/hibernate a thread.

Purpose of creating Threads:

Opens a new execution path, runs the specified code, and runs concurrently with the code implementation in the main thread.

Multi-Task scheduling system:

Each application is allocated by the operating system for a short time slice (timeslice) in turn using the CPU, because the CPU to each time slice processing speed very quickly, therefore, the user appears that these tasks seem to be executed simultaneously.

Concurrent:

Refers to two or more tasks occurring at the same time interval, but at any point in time, the CPU will only process one task.

Advantages of Multithreading:

1> takes full advantage of multi-core processor, assigning different thread tasks to different processors and really entering the "parallel operation" state;

2> allocates time-consuming tasks to other threads, and the unified update interface from the main thread will make the application smoother and the user experience better;

3> when the number of hardware processors increases, the program runs faster, and the program does not need to make any adjustments.

Disadvantages:

New threads consume memory space and CPU time, and too many threads can degrade the performance of the system.

The main difference between processes and threads is that they are different ways to manage operating system resources. The process has a separate address space, and after a process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process. Threads have their own stacks and local variables, but there is no separate address space between the threads, and a thread that dies equals the entire process dead.

iOS Processes and Threads

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.