现在的位置: 首页 > 综合 > 正文

Boost.Threads

2013年12月11日 ⁄ 综合 ⁄ 共 1529字 ⁄ 字号 评论关闭

From:http://www.boost.org/doc/libs/1_31_0/libs/thread/doc/definitions.html

Definitions

Thread

Thread is short for "thread of execution". A thread of execution is an execution environment [1.9/7] within the execution environment of a C++ program [1.9]. The main() function [3.6.1] of the program is the initial
function of the initial thread. A program in a multithreading environment always has an initial thread even if the program explicitly creates no additional threads.

Unless otherwise specified, each thread shares all aspects of its execution environment with other threads in the program. Shared aspects of the execution environment include, but are not limited to, the following:

  • Static storage duration (static, extern) objects [3.7.1].
  • Dynamic storage duration (heap) objects [3.7.3]. Thus each memory allocation will return a unique addresses, regardless of the thread making the allocation request.
  • Automatic storage duration (stack) objects [3.7.2] accessed via pointer or reference from another thread.
  • Resources provided by the operating system. For example, files.
  • The program itself. In other words, each thread is executing some function of the same program, not a totally different program.

Each thread has its own:

  • Registers and current execution sequence (program counter) [1.9/5].
  • Automatic storage duration (stack) objects [3.7.2].

Thread-safe

A program is thread-safe if it has no race conditions, does not deadlock,
and has no priority failures.

Note that thread-safety does not necessarily imply efficiency, and than while some thread-safety violations can be determined statically at compile time, many thread-safety errors can only only be detected at runtime.

Thread State

During the lifetime of a thread, it shall be in one of the following states:

抱歉!评论已关闭.