Linux environment programming-the attributes of threads

1. Thread attribute introduction-the second parameter of pthread_create [ pthread_attr_t data structure, red key control ]
To set thread attributes, for example, you can reduce memory usage by setting the size of the thread stack and increase the maximum number of threads.
typedef struct
{

  • int etachstate;//Thread separation state
  • int schedpolicy;//Thread scheduling strategy
  • struct sched_param schedparam;//Thread scheduling parameters
  • int inheritsched;//Thread inheritance
  • int scope; //The scope of the thread 
  • size_t guardsize;//The size of the guard buffer at the end of the thread stack
  • int stackaddr_set;//Thread stack setting
  • void* stackaddr;//The position of the thread stack
  • size_t stacksize;//The size of the thread stack

}pthread_attr_t;
This section serves as a guideline. The attributes of threads under linux can be set according to actual project needs. The threads we discussed before use the default attributes of threads. The default attributes can solve most development problems.

Guess you like

Origin blog.csdn.net/qq_44065088/article/details/109175651