"Linux Advanced Programming" (12th) Linux multithreaded Programming 4

Source: Internet
Author: User

Read/write Lock

The book has the reader's code, I really do not bother to realize it again. Similar to the previous code.

Multi-threaded asynchronous signal processing

int Pthread_kill (pthread_t __threadid, int __signo) : Sends a signal. A second parameter of 0 indicates that the specified thread is detected for existence. Successful return 0.

int pthread_sigmask (int __how, __const __sigset_t *__restrict __newmask, __sigset_t * __restrict __oldmask) : Set adjustment Use the thread's signal mask.

Parameter one: Presentation methods, including Sig_block, Sig_unblock, Sig_setmask

There is an example in the book, too lazy to copy ....

Thread Property Control

The thread property structure includes

pthread_t pthread_self (void) : Gets the thread ID. The ID is unique within a process, but may be the same in a different process.

syscall (Sys_gettid) : Gets the PID of the thread, is unique. Cannot view with PS command

int Pthread_attr_init (pthread_attr_t *__attr) : Initialize Thread Property Object

The default property values are:

int Pthread_attr_destroy (pthread_attr_t *__attr) : Destroys a thread property that has already been initialized

Get/Set thread detach state or can connect state

int pthread_attr_setdetachstate (pthread_attr_t *__attr, int __detachstate) : Set Detachstate Property

  pthread_create_detached : In a detached state

  pthread_create_joinable : Can connect status (default)

int pthread_attr_getdetachstate (__const pthread_attr_t *__attr, int *__detachstate) : Get Detachstate Property

Stack-related properties

int pthread_attr_setstacksize (pthread_attr_t *__attr, size_t __stacksize) : Sets the stack size pthread_stack_min represents the minimum value, The other numbers are the exact values.

int pthread_attr_getstacksize (__const pthread_attr_t *__restrict __attr, size_t *__restrict __stacksize) : Get stack size

int pthread_attr_setstackaddr (pthread_attr_t *__attr, void *__stackaddr) : Set Stack address

int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr) : Get the Stack address

int pthread_attr_setguardsize (pthread_attr_t *__attr, size_t __guardsize) : Sets the stack protection size. For overflow protection.

int pthread_attr_getguardsize (__const pthread_attr_t *__attr, size_t *__guardsize) : Gets the stack protection size.

"Linux Advanced Programming" (12th) Linux multithreaded Programming 4

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.