多线程编程中的公平性是什么? [英] What is fairness in multi-threading programming?

查看:136
本文介绍了多线程编程中的公平性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是并发/多线程编程中的线程公平性?

What is thread fairness or fairness in concurrent/multi-threaded programming?

我已经搜索了很多关于多线程的信息,但并不完全是关于公平的信息.

I have googled, there is loads of info on multi-threading but not exactly on fairness.

有人可以解释.一个例子是最受欢迎的.

Can some one explain. An example is most welcome.

推荐答案

公平基本上类似于不同线程在执行任何操作时能够 advance 的可能性. 100%的公平性是指:所有线程应以几乎相等的比例来推进其工作;公平性为0%意味着一个线程可能一直在前进,而其他所有线程则永远(或几乎永远)没有进展.

Fairness basically resembles to the likelihood that different threads are able to advance whatever they are doing. 100% fairness means: all threads should be advancing their work in almost equal portions; 0% fairness means that one single thread might be advancing all the time, and all other threads never (or almost never) make any progress.

这在很大程度上取决于您的要求,究竟究竟要求或实现什么公平.

It very much depends on your requirements how exactly fairness is required or achieved.

示例:zOS操作系统具有一个名为

Example: the zOS operating system has a component called the workload manager. This component works policy based. It allows you to say for example: "no matter what, I want that application X always gets 80% of CPU power; Y is important too, Z I dont care". That could mean: when the system gets under intensive load (so 100% of the CPUs consumed all the time) - X gets 80%, Y gets 20%, and Z gets nothing.

将此进程"视图深入到线程:在不公平设置中,线程可能饥饿.含义:某些线程能够前进,而其他线程则永远不会获得CPU周期,因此它们永远不会执行应做的事情.并且请注意:线程公平性没有(必要)连接到系统负载.

Taking this "process" view down to threads: in an unfair setup, threads might be starving. Meaning: some threads are able to advance, but other threads never get CPU cycles, therefore they can never do what they are supposed to do. And please note: thread fairness is not (necessarily) connected to system load.

请参见此处进行进一步阅读.

See here for further reading.

这篇关于多线程编程中的公平性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆