Properties of the [Linux Basic foundation]----thread

Source: Internet
Author: User

In the case of semaphores and mutexes, we use Pthread_join to synchronize threads again before the program is launched.
If you want the thread that threads wants to create it to return data I need to do this;
Problem: Sometimes we don't need a second thread to return information to the main thread, and we don't want the main thread to wait for it to end;
This means that when the main thread is working, the second thread is created, and the second thread is working to the end without having to write new information to the main thread;
================
Detach Thread, detaced thread
Modify the thread properties or call the Pthread_detach method to resolve
======
#include <pthread.h>
int Pthread_attr_init (pthread_attr_t *attr);
int Pthread_attr_destroy ()

int pthread_attr_setdetachstate (pthread_attr_t *attr,int detachstate);
int pthread_attr_getdatachstate (const pthread_attr_t *attr,int *detachstate);

int Pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
int Pthread_attr_getschedpolicy (const pthread_attr_t *attr,int *policy)

int Pthread_attr_setschedparam
int Pthread_attr_getschedparam

int pthread_attr_setinheritsched
int pthread_attr_getinheritsched

int Pthread_attr_setscope (
int Pthread_attr_getscope

int Pthread_attr_setstacksize
int Pthread_attr_getstacksize
Detachedstate: Property runs we don't need to re-merge threads, like most _set, a property pointer and a flag as parameters to determine the desired state
The two flags that may be used by the Set function are pthread_create_joinable (the default flag value), pthread_create_detached (if you choose this, you cannot use Pthread_join to get the exit status of another thread)
Shedpolicy controls how threads are dispatched,
Sched_other,sched_rp,sched_fifo







                         ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                 &NBSP;                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                 &NBSP                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp       '

[Linux Basic foundation]----Thread's properties

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.