Linux thread stack size
What's the difference between a subversive framework and a thread pool?

Disruptor framework is a high-performance asynchronous processing framework, which can also be regarded as the fastest message framework (lightweight JMS), and can also be regarded as the implementation of an observer mode or an event listening mode.

Thread pool is a form of multithreading, in which tasks are added to the queue during processing, and then these tasks are automatically started after threads are created. Thread pool threads are all background threads. Each thread uses the default stack size, runs with the default priority, and is located in a multithreaded unit.

How reasonable is the ulimit setting in the production environment?

Add ulimit-sunlimited to save at the end of /etc/profile, and source/etc/profile will make the modified file effective.

Linux View and Modify the Default Stack Space Size of Threads: ulimit-s

1. Check the default stack space size of linux through ulimit-s command, which is 10240 or 10M by default.

2. Set the size value through ulimit-s command to temporarily change the stack space size: ulimit-s, that is, modify it to1100mm.

3. You can add ulimit-s in /etc/rc.local, and then set the stack space when starting the machine.

4. The size of the stack space can also be changed in /etc/security/limits.conf:

#

* Soft stack

Log in again and execute ulimit-s, and you will see that it has been changed to1000 mm.

In what must the cpu thread information be saved?

When the process changes from execution state to ready state, CPU thread information must be saved in PCB.

The instructions and data currently being executed by CPU must be stored in memory, which has heap memory and stack memory. CPU can directly access memory data, and hard disk data must be imported into memory before it can be used! CPU-> memory-> hard disk. When needed, the data on the external memory will be read into the memory.

Golang thread pool principle?

Golang thread pool belongs to object pool. All object pools have a very important * * * attribute, which is to reuse objects to the greatest extent. Then the thread pool is the most.

The important feature is to make maximum use of threads.

First of all, creating the thread itself requires extra overhead (relative to the resources needed to perform the task).

When the operating system creates a thread, it needs to create at least the following resources:

(1) Thread kernel object: used to manage thread context.

(2) User-mode execution stack.

(3) Kernel mode execution stack.

After these resources are occupied by threads, neither the operating system nor users can use them.

On the contrary, destroying threads requires recycling resources and some overhead.

Secondly, too many threads will lead to excessive switching. The performance brought by thread switching is immeasurable. The system must complete thread switching through the following process:

(1) Switch from user mode to kernel mode.

(2) Save the value of the cpu register to the kernel object of the current thread.

(3) Open a spin lock and decide the next thread to be executed according to the scheduling strategy. If the thread to be executed is not in the same thread, the spin lock is released.

Threads in a process also need to switch process environments, such as virtual memory.

(4) Write the value of the kernel object of the thread to be executed into the cpu register.

(5) Switch to user mode and execute the execution logic of the new thread.

Therefore, the purpose of thread pool is to reduce the extra cost of creating and switching threads, and to repeatedly perform multiple tasks by using existing threads.

High system processing capacity.