有品味什么意思| 1942年属什么生肖| 鼻子上的痣有什么寓意| 上海手表什么档次| o型血生的孩子是什么血型| rt是什么意思| 肝内血管瘤是什么意思| 慈禧和光绪是什么关系| 什么是薪级工资| 牛的三合和六个合生肖是什么| 空调扇的冰晶是什么| 舌头烧灼感吃什么药| 恶心想吐肚子疼是什么原因| 一个月来两次月经是什么原因| 藜麦是什么| 夕阳无限好只是近黄昏是什么意思| 腹部包块是什么样子的| py交易是什么意思| 卵巢畸胎瘤是什么病| 腰疼吃点什么药| 什么是公元前和公元后| 搬家有什么讲究和忌讳| 是什么车| 憋气是什么意思| 长期吃阿司匹林有什么副作用| 拜阿司匹林什么时间吃最好| 性病是什么病| 不对劲是什么意思| 农历11月18日是什么星座| 红绿色盲是什么遗传| 预谋是什么意思| 89是什么意思| 藿香正气水什么人不能喝| 橙字五行属什么| 蜘蛛为什么不是昆虫| 葡挞跟蛋挞有什么区别| 微创手术是什么| 福禄寿是什么意思| 稻花鱼是什么鱼| 男人气血不足吃什么药| 什么工作赚钱| 社区医院属于什么级别| 怀孕第一个月有什么反应| 十月初三是什么星座| 婴儿胀气是什么原因| 皮试是什么| 素土是什么| 昭和是什么意思| 赤诚相见是什么意思| 排卵期是什么时候开始算| 口吐白沫是什么病| 腰椎间盘突出压迫神经吃什么药| 金牛女喜欢什么样的男生| 万象更新是什么生肖| 血管痉挛是什么症状| 沙茶酱做什么菜最好吃| 藕粉不能和什么一起吃| 凤梨是什么| 糖宝是什么虫| 气色是什么意思| 尼龙属于什么材料| 跳槽是什么意思| 小太阳是什么牌子| 癫痫病吃什么药最好| 倒三角是什么意思| 不知道干什么| 大便特别臭是什么原因| 大小三阳是什么病| 血常规白细胞偏高是什么原因| 屁股疼什么原因| 总是放屁是什么原因| 犀牛吃什么| 甲亢甲减有什么症状| 为什么舌头老是有灼烧感| 1月什么星座| 失焦是什么意思| 女的肾虚是什么原因引起的| 2001年是什么生肖| 梅雨季节是什么时候| 欧代是什么| 双侧肾盂分离是什么意思| 五台山是求什么的| 楼凤是什么意思| 二尖瓣关闭不全是什么意思| 奶嚼口是什么| 75是什么意思| 小学生什么时候开学| 犬和狗有什么区别| 手指甲上的月牙代表什么| 吃牛油果有什么好处| 微信上面有个耳朵是什么意思| 烤麸是用什么做的| 丝瓜什么时候种植最好| 兵马俑什么时候发现的| 黑色碎花裙配什么上衣| 贤惠是什么意思| 梦见亲人死了是什么意思| 手链突然断了预示什么| 辣椒什么时候种| 什么是做功| jeep是什么意思| 张家界地貌属于什么地貌| 肉松可以做什么美食| 蔻驰手表属于什么档次| 摩羯女和什么星座最配| 星座之王是什么座| 50岁属什么| abr是什么意思| 什么是科学| cmb是什么意思| 天秤男和什么星座最配| advil是什么药| 肾上腺瘤吃什么药可以消除| 肺大泡是什么原因造成的| 为什么养鱼双数是大忌| btc是什么货币| 嗓子吞咽疼痛吃什么药| nasa是什么意思| 龋读什么| 蒂芙尼算什么档次| 女人身体弱带什么辟邪| 凉皮加什么才柔软筋道| 晕车吃什么药| 为什么喜欢秋天| 孕妇梦见掉牙齿是什么意思| 莀字五行属什么| kgs是什么单位| 腹膜刺激征是指什么| 什么是荷尔蒙| 不生孩子的叫什么族| 化疗后吃什么食物最好| 有结石不能吃什么东西| 很容易出汗是什么原因| 眼睛肿疼是什么原因引起的| 3.21什么星座| 喉咙痛咽口水都痛吃什么药| 金灿灿的什么| 心得安又叫什么名| camel是什么颜色| 林冲到底属什么生肖的| 胃疼吃什么食物对胃好| 前列腺钙化是什么原因引起的| 什么叫阈值| 1950年是什么年| gap什么意思| 孕早期胎停有什么症状或征兆吗| 1987年出生属什么生肖| 艾滋病有什么特征| 绝倒是什么意思| 动车是什么| 蜜袋鼯吃什么| 宫颈醋酸白色上皮是什么病变| 连号的钱为什么不能花| 1935年是什么生肖| 舌尖发麻是什么病的前兆| 喜欢闻汽油味是什么原因| 生物制剂是什么| 飞机杯什么意思| 狗拉肚子吃什么药| 冠状沟是什么位置| 砭石是什么石头| 灰色鞋子搭配什么颜色裤子| 五花八门是什么意思| 梦见下雪是什么征兆| 男子精少吃什么药可以生精| 鹅蛋脸适合什么样的发型| 麦冬有什么作用| 胎监什么时候开始做| 什么叫软文| 茉莉花茶属于什么茶类| 朱元璋是什么生肖| 大姨妈为什么会推迟| 美丽的邂逅是什么意思| 备孕不能吃什么| lca是什么意思| 拉屎发黑是什么原因| 鹿字五行属什么| 牙膏属于什么类商品| 湿疹吃什么| 母亲节在什么时候| 热毒吃什么药好得快| 二月二十二日是什么星座| 学护理需要什么条件| 怀孕前三个月需要注意什么| 一点点奶茶什么最好喝| 复方北豆根氨酚那敏片是什么药| 软糯什么意思| ab是什么血型| 带下病是什么病| 处方药是什么标志| ushi是什么品牌男装| kpa什么意思| 氨咖黄敏胶囊是治什么的| 甘薯是什么东西| 肺癌不能吃什么水果| 取环后要注意什么事项| 阿卡波糖什么时候吃| 鹦鹉喜欢吃什么东西| lady是什么意思啊| 6月27号是什么星座| 大头虾是什么意思| 飞机为什么不能说一路顺风| 下肢血液循环不好吃什么药| 快递什么时候上班| 什么牌子的大米好吃| hpv68阳性是什么意思| 叶酸对人体有什么好处| 女人手指粗短是什么命| 财运亨通是什么意思| 左边肋骨下面是什么器官| 保妇康栓是治疗什么的| 怀孕肚子胀是什么原因| 属虎的生什么属相的宝宝好| 挑拨离间是什么意思| 广字五行属什么| 马齿苋长什么样子| 什么是基础代谢| berries什么意思| 打嗝吃什么药| 早上起来流鼻血是什么原因| 血小板减少吃什么药| 胃阳不足吃什么中成药| 向日葵什么时候播种| 蹉跎是什么意思| sansui是什么牌子| 压车是什么意思| 阴间是什么意思| 弹性是什么意思| 4月16日什么星座| CRL是胎儿的什么意思| 什么屈膝| 屁多还臭是什么原因| 夏枯草长什么样子| 五月二十四是什么星座| silence是什么意思| 金色配什么颜色好看| 锁骨上的痣代表什么| 乌鸡放什么炖补气补血| 小腿出汗是什么原因| 白血病是什么原因引起的| 便秘是什么症状| 贲门ca是什么意思| 林心如什么学历| 海马有什么功效作用| 射精无力吃什么药最佳| 茭白是什么植物| peak是什么牌子| 傲慢表情是什么意思| norm什么意思| 汗血宝马什么意思| 马克华菲是什么档次| 三净肉指什么| 没晨勃说明什么问题| 艾灸为什么不能天天灸| 算五行缺什么免费测试| 什么叫做罹患疾病| 结婚登记需要什么材料| 欲是什么意思| 什么是童话故事| 镶牙与种牙有什么区别| 名节是什么意思| 梨的功效与作用是什么| 冶游史是什么意思| 吃什么化痰效果最好最快| 百度Jump to content

华为荣耀magic和苹果iPhone7哪个好用?荣耀magic

From Wikipedia, the free encyclopedia
(Redirected from Thread (computer science))
A process with two threads of execution, running on one processor
Program vs. process vs. thread
scheduling, preemption, context switching
百度 同时,还提议,参加活动的男同志要充分尊重女性、照顾好身边的女同志,给她们更多的关怀与帮助!  中心女同志纷纷表示,一定不辜负刘敏主任的期望,努力提升自我,完善自我,做一个自信、幸福的女人!

In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system.[1] In many cases, a thread is a component of a process.

The multiple threads of a given process may be executed concurrently (via multithreading capabilities), sharing resources such as memory, while different processes do not share these resources. In particular, the threads of a process share its executable code and the values of its dynamically allocated variables and non-thread-local global variables at any given time.

The implementation of threads and processes differs between operating systems.[2][page needed]

History

[edit]

Threads made an early appearance under the name of "tasks" in IBM's batch processing operating system, OS/360, in 1967. It provided users with three available configurations of the OS/360 control system, of which multiprogramming with a variable number of tasks (MVT) was one. Saltzer (1966) credits Victor A. Vyssotsky with the term "thread".[3]

The use of threads in software applications became more common in the early 2000s as CPUs began to utilize multiple cores. Applications wishing to take advantage of multiple cores for performance advantages were required to employ concurrency to utilize the multiple cores.[4]

[edit]

Scheduling can be done at the kernel level or user level, and multitasking can be done preemptively or cooperatively. This yields a variety of related concepts.

Processes

[edit]

At the kernel level, a process contains one or more kernel threads, which share the process's resources, such as memory and file handles – a process is a unit of resources, while a thread is a unit of scheduling and execution. Kernel scheduling is typically uniformly done preemptively or, less commonly, cooperatively. At the user level a process such as a runtime system can itself schedule multiple threads of execution. If these do not share data, as in Erlang, they are usually analogously called processes,[5] while if they share data they are usually called (user) threads, particularly if preemptively scheduled. Cooperatively scheduled user threads are known as fibers; different processes may schedule user threads differently. User threads may be executed by kernel threads in various ways (one-to-one, many-to-one, many-to-many). The term light-weight process variously refers to user threads or to kernel mechanisms for scheduling user threads onto kernel threads.

A process is a heavyweight unit of kernel scheduling, as creating, destroying, and switching processes is relatively expensive. Processes own resources allocated by the operating system. Resources include memory (for both code and data), file handles, sockets, device handles, windows, and a process control block. Processes are isolated by process isolation, and do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way – see Interprocess communication. Creating or destroying a process is relatively expensive, as resources must be acquired or released. Processes are typically preemptively multitasked, and process switching is relatively expensive, beyond basic cost of context switching, due to issues such as cache flushing (in particular, process switching changes virtual memory addressing, causing invalidation and thus flushing of an untagged translation lookaside buffer (TLB), notably on x86).

Kernel threads

[edit]

A kernel thread is a lightweight unit of kernel scheduling. At least one kernel thread exists within each process. If multiple kernel threads exist within a process, then they share the same memory and file resources. Kernel threads are preemptively multitasked if the operating system's process scheduler is preemptive. Kernel threads do not own resources except for a stack, a copy of the registers including the program counter, and thread-local storage (if any), and are thus relatively cheap to create and destroy. Thread switching is also relatively cheap: it requires a context switch (saving and restoring registers and stack pointer), but does not change virtual memory and is thus cache-friendly (leaving TLB valid). The kernel can assign one or more software threads to each core in a CPU (it being able to assign itself multiple software threads depending on its support for multithreading), and can swap out threads that get blocked. However, kernel threads take much longer than user threads to be swapped.

User threads

[edit]

Threads are sometimes implemented in userspace libraries, thus called user threads. The kernel is unaware of them, so they are managed and scheduled in userspace. Some implementations base their user threads on top of several kernel threads, to benefit from multi-processor machines (M:N model). User threads as implemented by virtual machines are also called green threads.

As user thread implementations are typically entirely in userspace, context switching between user threads within the same process is extremely efficient because it does not require any interaction with the kernel at all: a context switch can be performed by locally saving the CPU registers used by the currently executing user thread or fiber and then loading the registers required by the user thread or fiber to be executed. Since scheduling occurs in userspace, the scheduling policy can be more easily tailored to the requirements of the program's workload.

However, the use of blocking system calls in user threads (as opposed to kernel threads) can be problematic. If a user thread or a fiber performs a system call that blocks, the other user threads and fibers in the process are unable to run until the system call returns. A typical example of this problem is when performing I/O: most programs are written to perform I/O synchronously. When an I/O operation is initiated, a system call is made, and does not return until the I/O operation has been completed. In the intervening period, the entire process is "blocked" by the kernel and cannot run, which starves other user threads and fibers in the same process from executing.

A common solution to this problem (used, in particular, by many green threads implementations) is providing an I/O API that implements an interface that blocks the calling thread, rather than the entire process, by using non-blocking I/O internally, and scheduling another user thread or fiber while the I/O operation is in progress. Similar solutions can be provided for other blocking system calls. Alternatively, the program can be written to avoid the use of synchronous I/O or other blocking system calls (in particular, using non-blocking I/O, including lambda continuations and/or async/await primitives[6]).

Fibers

[edit]

Fibers are an even lighter unit of scheduling which are cooperatively scheduled: a running fiber must explicitly yield to allow another fiber to run, which makes their implementation much easier than kernel or user threads. A fiber can be scheduled to run in any thread in the same process. This permits applications to gain performance improvements by managing scheduling themselves, instead of relying on the kernel scheduler (which may not be tuned for the application). Some research implementations of the OpenMP parallel programming model implement their tasks through fibers.[7][8] Closely related to fibers are coroutines, with the distinction being that coroutines are a language-level construct, while fibers are a system-level construct.

Threads vs processes

[edit]

Threads differ from traditional multitasking operating-system processes in several ways:

  • processes are typically independent, while threads exist as subsets of a process
  • processes carry considerably more state information than threads, whereas multiple threads within a process share process state as well as memory and other resources
  • processes have separate address spaces, whereas threads share their address space
  • processes interact only through system-provided inter-process communication mechanisms
  • context switching between threads in the same process typically occurs faster than context switching between processes

Systems such as Windows NT and OS/2 are said to have cheap threads and expensive processes; in other operating systems there is not so great a difference except in the cost of an address-space switch, which on some architectures (notably x86) results in a translation lookaside buffer (TLB) flush.

Advantages and disadvantages of threads vs processes include:

  • Lower resource consumption of threads: using threads, an application can operate using fewer resources than it would need when using multiple processes.
  • Simplified sharing and communication of threads: unlike processes, which require a message passing or shared memory mechanism to perform inter-process communication (IPC), threads can communicate through data, code and files they already share.
  • Thread crashes a process: due to threads sharing the same address space, an illegal operation performed by a thread can crash the entire process; therefore, one misbehaving thread can disrupt the processing of all the other threads in the application.

Scheduling

[edit]

Preemptive vs cooperative scheduling

[edit]

Operating systems schedule threads either preemptively or cooperatively. Multi-user operating systems generally favor preemptive multithreading for its finer-grained control over execution time via context switching. However, preemptive scheduling may context-switch threads at moments unanticipated by programmers, thus causing lock convoy, priority inversion, or other side-effects. In contrast, cooperative multithreading relies on threads to relinquish control of execution, thus ensuring that threads run to completion. This can cause problems if a cooperatively-multitasked thread blocks by waiting on a resource or if it starves other threads by not yielding control of execution during intensive computation.

Single- vs multi-processor systems

[edit]

Until the early 2000s, most desktop computers had only one single-core CPU, with no support for hardware threads, although threads were still used on such computers because switching between threads was generally still quicker than full-process context switches. In 2002, Intel added support for simultaneous multithreading to the Pentium 4 processor, under the name hyper-threading; in 2005, they introduced the dual-core Pentium D processor and AMD introduced the dual-core Athlon 64 X2 processor.

Systems with a single processor generally implement multithreading by time slicing: the central processing unit (CPU) switches between different software threads. This context switching usually occurs frequently enough that users perceive the threads or tasks as running in parallel (for popular server/desktop operating systems, maximum time slice of a thread, when other threads are waiting, is often limited to 100–200ms). On a multiprocessor or multi-core system, multiple threads can execute in parallel, with every processor or core executing a separate thread simultaneously; on a processor or core with hardware threads, separate software threads can also be executed concurrently by separate hardware threads.

Threading models

[edit]

1:1 (kernel-level threading)

[edit]

Threads created by the user in a 1:1 correspondence with schedulable entities in the kernel[9] are the simplest possible threading implementation. OS/2 and Win32 used this approach from the start, while on Linux the GNU C Library implements this approach (via the NPTL or older LinuxThreads). This approach is also used by Solaris, NetBSD, FreeBSD, macOS, and iOS.

M:1 (user-level threading)

[edit]

An M:1 model implies that all application-level threads map to one kernel-level scheduled entity;[9] the kernel has no knowledge of the application threads. With this approach, context switching can be done very quickly and, in addition, it can be implemented even on simple kernels which do not support threading. One of the major drawbacks, however, is that it cannot benefit from the hardware acceleration on multithreaded processors or multi-processor computers: there is never more than one thread being scheduled at the same time.[9] For example: If one of the threads needs to execute an I/O request, the whole process is blocked and the threading advantage cannot be used. The GNU Portable Threads uses User-level threading, as does State Threads.

M:N (hybrid threading)

[edit]

M:N maps some M number of application threads onto some N number of kernel entities,[9] or "virtual processors." This is a compromise between kernel-level ("1:1") and user-level ("N:1") threading. In general, "M:N" threading systems are more complex to implement than either kernel or user threads, because changes to both kernel and user-space code are required[clarification needed]. In the M:N implementation, the threading library is responsible for scheduling user threads on the available schedulable entities; this makes context switching of threads very fast, as it avoids system calls. However, this increases complexity and the likelihood of priority inversion, as well as suboptimal scheduling without extensive (and expensive) coordination between the userland scheduler and the kernel scheduler.

Hybrid implementation examples

[edit]

History of threading models in Unix systems

[edit]

SunOS 4.x implemented light-weight processes or LWPs. NetBSD 2.x+, and DragonFly BSD implement LWPs as kernel threads (1:1 model). SunOS 5.2 through SunOS 5.8 as well as NetBSD 2 to NetBSD 4 implemented a two level model, multiplexing one or more user level threads on each kernel thread (M:N model). SunOS 5.9 and later, as well as NetBSD 5 eliminated user threads support, returning to a 1:1 model.[10] FreeBSD 5 implemented M:N model. FreeBSD 6 supported both 1:1 and M:N, users could choose which one should be used with a given program using /etc/libmap.conf. Starting with FreeBSD 7, the 1:1 became the default. FreeBSD 8 no longer supports the M:N model.

Single-threaded vs multithreaded programs

[edit]

In computer programming, single-threading is the processing of one instruction at a time.[11] In the formal analysis of the variables' semantics and process state, the term single threading can be used differently to mean "backtracking within a single thread", which is common in the functional programming community.[12]

Multithreading is mainly found in multitasking operating systems. Multithreading is a widespread programming and execution model that allows multiple threads to exist within the context of one process. These threads share the process's resources, but are able to execute independently. The threaded programming model provides developers with a useful abstraction of concurrent execution. Multithreading can also be applied to one process to enable parallel execution on a multiprocessing system.

Multithreading libraries tend to provide a function call to create a new thread, which takes a function as a parameter. A concurrent thread is then created which starts running the passed function and ends when the function returns. The thread libraries also offer data synchronization functions.

Threads and data synchronization

[edit]

Threads in the same process share the same address space. This allows concurrently running code to couple tightly and conveniently exchange data without the overhead or complexity of an IPC. When shared between threads, however, even simple data structures become prone to race conditions if they require more than one CPU instruction to update: two threads may end up attempting to update the data structure at the same time and find it unexpectedly changing underfoot. Bugs caused by race conditions can be very difficult to reproduce and isolate.

To prevent this, threading application programming interfaces (APIs) offer synchronization primitives such as mutexes to lock data structures against concurrent access. On uniprocessor systems, a thread running into a locked mutex must sleep and hence trigger a context switch. On multi-processor systems, the thread may instead poll the mutex in a spinlock. Both of these may sap performance and force processors in symmetric multiprocessing (SMP) systems to contend for the memory bus, especially if the granularity of the locking is too fine.

Other synchronization APIs include condition variables, critical sections, semaphores, and monitors.

Thread pools

[edit]

A popular programming pattern involving threads is that of thread pools where a set number of threads are created at startup that then wait for a task to be assigned. When a new task arrives, it wakes up, completes the task and goes back to waiting. This avoids the relatively expensive thread creation and destruction functions for every task performed and takes thread management out of the application developer's hand and leaves it to a library or the operating system that is better suited to optimize thread management.

Multithreaded programs vs single-threaded programs pros and cons

[edit]

Multithreaded applications have the following advantages vs single-threaded ones:

  • Responsiveness: multithreading can allow an application to remain responsive to input. In a one-thread program, if the main execution thread blocks on a long-running task, the entire application can appear to freeze. By moving such long-running tasks to a worker thread that runs concurrently with the main execution thread, it is possible for the application to remain responsive to user input while executing tasks in the background. On the other hand, in most cases multithreading is not the only way to keep a program responsive, with non-blocking I/O and/or Unix signals being available for obtaining similar results.[13]
  • Parallelization: applications looking to use multicore or multi-CPU systems can use multithreading to split data and tasks into parallel subtasks and let the underlying architecture manage how the threads run, either concurrently on one core or in parallel on multiple cores. GPU computing environments like CUDA and OpenCL use the multithreading model where dozens to hundreds of threads run in parallel across data on a large number of cores. This, in turn, enables better system utilization, and (provided that synchronization costs don't eat the benefits up), can provide faster program execution.

Multithreaded applications have the following drawbacks:

  • Synchronization complexity and related bugs: when using shared resources typical for threaded programs, the programmer must be careful to avoid race conditions and other non-intuitive behaviors. In order for data to be correctly manipulated, threads will often need to rendezvous in time in order to process the data in the correct order. Threads may also require mutually exclusive operations (often implemented using mutexes) to prevent common data from being read or overwritten in one thread while being modified by another. Careless use of such primitives can lead to deadlocks, livelocks or races over resources. As Edward A. Lee has written: "Although threads seem to be a small step from sequential computation, in fact, they represent a huge step. They discard the most essential and appealing properties of sequential computation: understandability, predictability, and determinism. Threads, as a model of computation, are wildly non-deterministic, and the job of the programmer becomes one of pruning that nondeterminism."[14]
  • Being untestable. In general, multithreaded programs are non-deterministic, and as a result, are untestable. In other words, a multithreaded program can easily have bugs which never manifest on a test system, manifesting only in production.[15][14] This can be alleviated by restricting inter-thread communications to certain well-defined patterns (such as message-passing).
  • Synchronization costs. As thread context switch on modern CPUs can cost up to 1 million CPU cycles,[16] it makes writing efficient multithreading programs difficult. In particular, special attention has to be paid to avoid inter-thread synchronization from being too frequent.

Programming language support

[edit]

Many programming languages support threading in some capacity.

  • IBM PL/I(F) included support for multithreading (called multitasking) as early as in the late 1960s, and this was continued in the Optimizing Compiler and later versions. The IBM Enterprise PL/I compiler introduced a new model "thread" API. Neither version was part of the PL/I standard.
  • Many implementations of C and C++ support threading, and provide access to the native threading APIs of the operating system. A standardized interface for thread implementation is POSIX Threads (Pthreads), which is a set of C-function library calls. OS vendors are free to implement the interface as desired, but the application developer should be able to use the same interface across multiple platforms. Most Unix platforms, including Linux, support Pthreads. Microsoft Windows has its own set of thread functions in the process.h interface for multithreading, like beginthread.
  • Some higher level (and usually cross-platform) programming languages, such as Java, Python, and .NET Framework languages, expose threading to developers while abstracting the platform specific differences in threading implementations in the runtime. Several other programming languages and language extensions also try to abstract the concept of concurrency and threading from the developer fully (Cilk, OpenMP, Message Passing Interface (MPI)). Some languages are designed for sequential parallelism instead (especially using GPUs), without requiring concurrency or threads (Ateji PX, CUDA).
  • A few interpreted programming languages have implementations (e.g., Ruby MRI for Ruby, CPython for Python) which support threading and concurrency but not parallel execution of threads, due to a global interpreter lock (GIL). The GIL is a mutual exclusion lock held by the interpreter that can prevent the interpreter from simultaneously interpreting the application's code on two or more threads at once. This effectively limits the parallelism on multiple core systems. It also limits performance for processor-bound threads (which require the processor), but doesn't effect I/O-bound or network-bound ones as much. Other implementations of interpreted programming languages, such as Tcl using the Thread extension, avoid the GIL limit by using an Apartment model where data and code must be explicitly "shared" between threads. In Tcl each thread has one or more interpreters.
  • In programming models such as CUDA designed for data parallel computation, an array of threads run the same code in parallel using only its ID to find its data in memory. In essence, the application must be designed so that each thread performs the same operation on different segments of memory so that they can operate in parallel and use the GPU architecture.
  • Hardware description languages such as Verilog have a different threading model that supports extremely large numbers of threads (for modeling hardware).

See also

[edit]

References

[edit]
  1. ^ Lamport, Leslie (September 1979). "How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs" (PDF). IEEE Transactions on Computers. C-28 (9): 690–691. doi:10.1109/tc.1979.1675439. S2CID 5679366.
  2. ^ Tanenbaum, Andrew S. (1992). Modern Operating Systems. Prentice-Hall International Editions. ISBN 0-13-595752-4.
  3. ^ Saltzer, Jerome Howard (July 1966). Traffic Control in a Multiplexed Computer System (PDF) (Doctor of Science thesis). p. 20.
  4. ^ Sutter, Herb (March 2005). "The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software". Dr. Dobb's Journal. 30 (3).
  5. ^ "Erlang: 3.1 Processes".
  6. ^ Ignatchenko, Sergey. Eight Ways to Handle Non-blocking Returns in Message-passing Programs: from C++98 via C++11 to C++20. CPPCON. Archived from the original on 2025-08-06. Retrieved 2025-08-06.{{cite AV media}}: CS1 maint: bot: original URL status unknown (link)
  7. ^ Ferat, Manuel; Pereira, Romain; Roussel, Adrien; Carribault, Patrick; Steffenel, Luiz-Angelo; Gautier, Thierry (September 2022). "Enhancing MPI+OpenMP Task Based Applications for Heterogeneous Architectures with GPU support" (PDF). OpenMP in a Modern World: From Multi-device Support to Meta Programming. IWOMP 2022: 18th International Workshop on OpenMP. Lecture Notes in Computer Science. Vol. 13527. pp. 3–16. doi:10.1007/978-3-031-15922-0_1. ISBN 978-3-031-15921-3. S2CID 251692327.
  8. ^ Iwasaki, Shintaro; Amer, Abdelhalim; Taura, Kenjiro; Seo, Sangmin; Balaji, Pavan. BOLT: Optimizing OpenMP Parallel Regions with User-Level Threads (PDF). The 28th International Conference on Parallel Architectures and Compilation Techniques.
  9. ^ a b c d Silberschatz, Abraham; Galvin, Peter Baer; Gagne, Greg (2013). Operating system concepts (9th ed.). Hoboken, N.J.: Wiley. pp. 170–171. ISBN 9781118063330.
  10. ^ "Multithreading in the Solaris Operating Environment" (PDF). 2002. Archived from the original (PDF) on February 26, 2009.
  11. ^ Menéndez, Raúl; Lowe, Doug (2001). Murach's CICS for the COBOL Programmer. Mike Murach & Associates. p. 512. ISBN 978-1-890774-09-7.
  12. ^ O'Hearn, Peter William; Tennent, R. D. (1997). ALGOL-like languages. Vol. 2. Birkh?user Verlag. p. 157. ISBN 978-0-8176-3937-2.
  13. ^ Ignatchenko, Sergey (August 2010). "Single-Threading: Back to the Future?". Overload (97). ACCU: 16–19.
  14. ^ a b Lee, Edward (January 10, 2006). "The Problem with Threads". UC Berkeley.
  15. ^ Ignatchenko, Sergey (August 2015). "Multi-threading at Business-logic Level is Considered Harmful". Overload (128). ACCU: 4–7.
  16. ^ 'No Bugs' Hare (12 September 2016). "Operation Costs in CPU Clock Cycles".

Further reading

[edit]
  • David R. Butenhof: Programming with POSIX Threads, Addison-Wesley, ISBN 0-201-63392-2
  • Bradford Nichols, Dick Buttlar, Jacqueline Proulx Farell: Pthreads Programming, O'Reilly & Associates, ISBN 1-56592-115-1
  • Paul Hyde: Java Thread Programming, Sams, ISBN 0-672-31585-8
  • Jim Beveridge, Robert Wiener: Multithreading Applications in Win32, Addison-Wesley, ISBN 0-201-44234-5
  • Uresh Vahalia: Unix Internals: the New Frontiers, Prentice Hall, ISBN 0-13-101908-2
40年是什么婚姻 吃什么能消除子宫肌瘤 胆囊粗糙是什么意思 3月12日是什么星座 11月18日什么星座
压力是什么 什么是继发性肺结核 下午四点是什么时辰 寅时是什么时间 淋巴结清扫是什么意思
逆钟向转位什么意思 点数是什么意思 2月28号是什么星座 单飞什么意思 小儿流清鼻涕吃什么药效果好
男性生殖器官叫什么 什么人容易得尿毒症 人流后能吃什么水果 小马拉大车什么意思 坦诚相待下一句是什么
脚心发痒是什么原因hcv9jop2ns2r.cn 广州为什么叫花城bjcbxg.com 备孕怀男孩做什么准备hcv8jop3ns3r.cn 误人子弟什么意思hcv7jop7ns4r.cn 入职offer是什么意思hebeidezhi.com
膀胱充盈差是什么意思hcv9jop5ns5r.cn 莲叶和荷叶有什么区别hcv8jop1ns2r.cn mopar是什么牌子hcv7jop7ns4r.cn 入驻是什么意思hcv8jop6ns6r.cn 早上七点是什么时辰hcv9jop7ns0r.cn
底线是什么意思hcv8jop0ns5r.cn 对什么有好处hanqikai.com cacao是什么意思beikeqingting.com 白斑有什么症状图片hcv8jop0ns4r.cn 住院需要带什么生活用品hcv7jop6ns6r.cn
肾病综合症是什么病imcecn.com 肾气虚吃什么中成药hcv9jop6ns6r.cn 一什么公园hcv8jop7ns0r.cn 烫伤用什么药最好hcv7jop6ns0r.cn 怀孕了用排卵试纸测会显示什么hcv9jop0ns6r.cn
百度