1、Linux There are two models for thread scheduling ,

One is completely responsible by the process , Start a thread scheduler in process , Scheduling is done by the thread scheduler in the process .

The disadvantage is that :(1) Each thread adds its own active release cpu The process of

(2) The process may block , It can't achieve the effect of multithreading . Because when a thread calls a blocking system call , It will cause the whole process to hang up , Because the thread scheduler in the process doesn't get the chance to run , therefore , There is no way to schedule other threads to run .

The other is to schedule by the kernel .

The disadvantage is that :(1) The kernel finishes scheduling , The burden of the kernel is heavy .

2、Linux Thread implementation of , There has been... In history Linux Thread and The modern version of NPTL.Linux Thread Although it can also achieve the effect of multithreading , But there are many limitations , and NPTL It's more in line Posix standard , Better performance when starting multiple threads within a process . In extreme cases , A process can start 10 000 threads , And use the traditional Linux Thread About thousands of threads are started . from Linux 2.6 Start , as well as glibc In the new version, it is turned on by default NPTL.

3、NPTL=native posix thread library

4、NPTL The thread implementation model of is as follows :

5、java Multi thread implementation of , By JVM Realized , The kernel doesn't care , But by the JVM Finish multithreading scheduling ,JVM Internal maintenance of a program to run the number of instructions counter , So that we know the running time of the thread , When a certain number of instructions is reached , Then forcibly deprive the thread of running , To schedule other threads to run ,java The priority of the thread is 10 individual , The default is 5, You can specify 1~10.

The basic principle is : Time slice rotation scheduling based on priority .

6、python Multi thread implementation of , To be improved .

Linux More articles on thread implementation model

  1. Linux Comparison of thread models :LinuxThreads and NPTL

    Linux Comparison of thread models :LinuxThreads and NPTL GNU_LIBPTHREAD_VERSION macro Most modern Linux The distribution is pre installed LinuxThreads and NPTL, because ...

  2. 【 turn 】linux Threading model

    One . Definition About the process . Lightweight process . Threads . User threads . The definition of kernel thread , This is easy to find , But after reading it, you can say you understand , But actually, do you really understand ? In modern operating systems , Processes support multithreading . Process is the smallest unit of resource management : And threads ...

  3. Linux Thread implementation mechanism analysis Linux Comparison of thread models :LinuxThreads and NPTL

    Linux Thread implementation mechanism analysis Linux Thread implementation mechanism analysis   Linux Comparison of thread models :LinuxThreads and NPTL http://www.ibm.com/developerworks/c ...

  4. Dubbo From beginners to proficient in learning notes ( 11、 ... and ):Dubbo Service startup dependency check 、Dubbo Load balancing strategy 、Dubbo Threading model ( combination Linux Live sharing of thread limit configuration )

    List of articles Dubbo Service startup dependency check Dubbo Load balancing strategy Dubbo Threading model ( combination Linux Live sharing of thread limit configuration ) Practical experience sharing ( ** Performance tuning for use **): Dubbo Service startup dependency check Du ...

  5. Linux Thread implementation mechanism analysis Linux Thread implementation mechanism analysis Linux Comparison of thread models :LinuxThreads and NPTL

    Linux Thread implementation mechanism analysis Linux Thread implementation mechanism analysis   Linux Comparison of thread models :LinuxThreads and NPTL http://www.ibm.com/developerworks/c ...

  6. [ turn ]Linux Thread implementation mechanism analysis Linux Thread implementation mechanism analysis Linux Comparison of thread models :LinuxThreads and NPTL

    Reprinted address :https://www.cnblogs.com/MYSQLZOUQI/p/4233630.html Since the concept of multithreaded programming appeared in Linux Since China ,Linux The development of multi line applications is always divorced from two problems ...

  7. [ Reprint ]Linux Thread implementation mechanism analysis

    In this paper, from http://www.ibm.com/developerworks/cn/linux/kernel/l-thread/ Support the original . Respect for the original , Share knowledge ! Since the concept of multithreaded programming appeared in Linux ...

  8. linux Implementation of threads

    First of all, from the OS The design principle clarifies three kinds of threads : Kernel thread . Lightweight process . User threads Kernel thread The kernel thread is the kernel part , A separation can deal with a specific thing . This is dealing with asynchronous events like asynchronous IO Especially useful when . The use of kernel threads is cheap , Only use ...

  9. linux Implementation of threads 【 turn 】

    from :http://www.cnblogs.com/zhaoyl/p/3620204.html First of all, from the OS The design principle clarifies three kinds of threads : Kernel thread . Lightweight process . User threads Kernel thread The kernel thread is the kernel part , One ...

Random recommendation

  1. CSS Manually change DIV Height and width

    This example code can make DIV You can change the size manually Effect experience :http://hovertree.com/code/css/resize.htm The code is as follows : <!DOCTYPE html> <ht ...

  2. OpenResty(nginx+lua) introduction

    OpenResty Official website :http://openresty.org/ OpenResty It's a nginx A packaged software platform with its various tripartite modules . The most important thing is that it will lua/luajit Packed in , ...

  3. HDU 5818 Joint Stacks( Union stack )

    HDU 5818 Joint Stacks( Union stack ) Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  4. Spring Framework acquisition datasource Object method

    1, Use org.springframework.jdbc.datasource.DriverManagerDataSource  2. Use org.apache.commons.dbcp.BasicDa ...

  5. matlab An example of solving the equation of

    syms x y z=exp(2*x+y)+cos(3*x*y)-exp(1)-1; zz=subs(z,x,1) solve(zz)

  6. 20 The best jQuery File upload plugin

    When it's about developing web applications and web pages , The importance of file upload function cannot be ignored . A file upload function allows you to upload all types of files on the website , Including video , Images , Documents and more . Create a file upload function , Is it hard for your website , Yes ...

  7. IIS8.5 Add configuration in the environment of WCF service !!!!!

    Add step : 1. open iis8.5, First deployment wcf service . 2. First add MIME type Extension :“.svc” MIME type :“application/octet-stream” 3. add to Handler mapping Request road ...

  8. C++ Achieve balanced binary tree

    1. Concept Balanced binary trees (AVL Tree) The first thing to do is to satisfy the definition of a binary tree , as follows Binary sort tree or an empty tree , Or a binary tree that has the following properties : If the left subtree is not empty , Then the value of all nodes in the left subtree is less than the value of its root node : If the right subtree is not empty , ...

  9. Python Development 【Django】: restructure Admin

    Customize KingAdmin adopt admin Make your own style KingAdmin What you need to know in advance model operation # obtain app name >>> models.Customer._meta.app_lab ...

  10. JS Find the least common multiple of an array element

    To find the least common multiple of several numbers is to find the least common multiple of the first two numbers , Then we put the least common multiple and the third number together to find the least common multiple , And so on ... var dbList = []; // The least common multiple of two numbers function ...