什么是民意调查,并选择之间的区别是什么? [英] What are the differences between poll and select?

查看:135
本文介绍了什么是民意调查,并选择之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我指POSIX标准选择并的民调系统C API调用。

I am referring to the POSIX standard select and poll system C API calls.

推荐答案

我觉得的答案你的问题:

I think that this answers your question:

从理查德·史蒂文斯(rstevens@noao.edu):

From Richard Stevens (rstevens@noao.edu):

的根本区别在于,选择()的FD_SET是一个位掩码和
  因此具有一定的固定大小。它将为内核成为可能
  当内核编译并不限制本尺寸,允许
  应用程序定义FD_SETSIZE来为所欲为(如注释
  在系统头暗示今天),但它需要更多的工作。 4.4BSD的
  内核和Solaris库函数都有此限制。但是我
  看到BSD / OS 2.1目前已被codeD来避免这种限制,所以它的
  可行的,只是编程的一个小问题。 :-)有人应提交
  在此Solaris bug报告,并查看它是否曾经得到固定。

The basic difference is that select()'s fd_set is a bit mask and therefore has some fixed size. It would be possible for the kernel to not limit this size when the kernel is compiled, allowing the application to define FD_SETSIZE to whatever it wants (as the comments in the system header imply today) but it takes more work. 4.4BSD's kernel and the Solaris library function both have this limit. But I see that BSD/OS 2.1 has now been coded to avoid this limit, so it's doable, just a small matter of programming. :-) Someone should file a Solaris bug report on this, and see if it ever gets fixed.

使用轮询(),但是,用户必须分配的pollfd的阵列
  结构,并通过条目数此数组中,所以有
  没有根本性的限制。由于卡斯帕指出,更少的系统有民调()比
  选择,所以后者更便于携带。此外,与原始
  实现(SVR3),你可以不设置描述为-1告诉
  内核忽略pollfd结构中的条目,这使得它
  难以除去从阵列条目; SVR4得到解决此问题。
  就个人而言,我总是使用select()和极少的poll(),因为我端口我
  code到BSD环境了。有人可以编写一个实现
  使用选择(),对于这些环境,但我从来没有投票()的
  见过。这两种选择()和poll()正在POSIX标准
  1003.1克。

With poll(), however, the user must allocate an array of pollfd structures, and pass the number of entries in this array, so there's no fundamental limit. As Casper notes, fewer systems have poll() than select, so the latter is more portable. Also, with original implementations (SVR3) you could not set the descriptor to -1 to tell the kernel to ignore an entry in the pollfd structure, which made it hard to remove entries from the array; SVR4 gets around this. Personally, I always use select() and rarely poll(), because I port my code to BSD environments too. Someone could write an implementation of poll() that uses select(), for these environments, but I've never seen one. Both select() and poll() are being standardized by POSIX 1003.1g.

这篇关于什么是民意调查,并选择之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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