POSIX thread Overview

Source: Internet
Author: User
1. Basic Concepts

A UNIX process can be understood as a thread plus an address space, a file descriptor, and other data.
Async shows that things happen independently of each other, unless there is an imposed dependency.

Concurrency refers to the fact that it's possible that things happen at the same time.
Parallelism refers to simultaneous execution of concurrent sequences.

Thread safety refers to the ability of code to be called by multiple threads without catastrophic consequences.

2. Shared data--synchronization object--mutex--relationship of conditional variables

The basic Pthread synchronization model uses mutexes to protect shared data and use conditional variables to communicate. A mutex allows a thread to lock it when it accesses shared data, allowing a thread to wait for the shared data to reach a desired state.

mutexes prevent unexpected collisions between threads.
The condition variable lets the thread wait to know that it can execute safely.
Both mutex and condition variables are used to synchronize inter-thread operations.

3. Common structure

Three basic elements of a threading system: Execution Environment, scheduling, synchronizing pthread_t thread identifiers
pthread_mutex_t Mutex Amount
pthread_code_t Condition variables
pthread_key_t thread private rights to hold access keys
pthread_attr_t Thread Property Object
pthread_condattr_t Condition Variable Property Object

4. Pthread Features

The errno variable is not set when the Pthread function is wrong.
There is no function in pthread that wants to perror the error message in the given format, it uses the Strerror function to get a description of the error code and then print it to stderr

POSIX thread Overview

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.