共8条 1/1
1
跳转至
页
VxWorks的文件描述符bug!?
![](http://m.amcfsurvey.com/uphotos//thumb/avatar.jpg)
在VxWorks中,用户文件描述符数目可以自己定的,其中0,1,2号文件描述符是为系统保留的标准输入、输 出和错误流。它不在用户的文件描述符表中,而用户文件描述表的大小为NUM_FILES个,所以用户的文件 描述符索引范围为从3开始一直到NUM_FILES+2。 按理说,用户可以得到系统分配的NUM_FILES个文件描述符,现在将设备可打开的文件个数设置为512个。 在configTms.h中将宏NUM_FILES的值设置为512。 然后试着先打开10个管道文件,再打开512个socket。原先预料的结果是socket所返回的文件描述符会一 直正确的返回到514,结果在创建到描述符值为512时便开始出错。这样便与其VxWorks文档中所说的不一 致了。因为它实际能使用的描述符个数只有NUM_FILES个(包含0,1,2),而不是NUM_FILES+2个。 在VxWorks 5.4.3中运行下附代码,使用devs查看当前所使用的设备,使用iosFdShow查看当前所使用的文 件描述符。 通过iosFdShow可以看到系统所维护的文件描述符表索引是从3到514。但512,513,514并不是成功创建的描述符,它们的设备号是一个错误值。 我想这是VxWorks中的bug。请大家验证一下,如果不是bug,还请高人解惑。 void abcdefghijklmnopq() { int sck = 0; int i=0; int sckCnt = 0; int pipeFd = 0; int pipeFdCnt = 0; printf("\ntry to open additional 10 pipes\n"); pipeDevCreate ("/pipe/filetest", 10, 100); for(i=0; i<10; i++) { pipeFd = open("/pipe/filetest", O_RDONLY, 0); if(pipeFd != -1) { printf("successfully open pipe /pipe/filetest, get fd %d\n", pipeFd); pipeFdCnt++; } else { printf("failed to open pipe /pipe/filetest in loop %d\n", i); } } printf("*****************************\n"); printf("TOTAL PipeFd Opened%d\n", pipeFdCnt); printf("*****************************\n"); printf("try to open 512 sockets!\n"); for (i=0; i<512; i++) { sck = socket( AF_INET, SOCK_DGRAM, 0); if(sck != -1) { printf("successfully open socket %d\n", sck); sckCnt++; } else { printf("failed to open socket in loop %d\n", i); } } printf("*****************************\n"); printf("TOTAL SOCKET OPENED %d\n", sckCnt); printf("*****************************\n"); } 这是设备及描述符查看结果。 -> devs drv name 0 /null 1 /tyCo/0 1 /tyCo/1 3 /tffs/ 5 host: 6 /vio 7 /tgtsvr 2 /pipe/snmpNotify 2 /pipe/dot1x 2 /pipe/dhcp 2 /pipe/timeout 2 /pipe/filetest value = 25 = 0x19 -> iosFdShow fd name drv 3 /tyCo/0 1 in out err 4 (socket) 4 5 (socket) 4 6 /pipe/dot1x 2 7 /pipe/dhcp 2 8 /pipe/timeout 2 9 (socket) 4 10 (socket) 4 11 /pipe/snmpNotify 2 12 (socket) 4 13 /pipe/filetest 2 14 /pipe/filetest 2 15 /pipe/filetest 2 ……………… ……………… 509 (socket) 4 510 (socket) 4 511 (socket) 4 512 (unknown) 8610 513 (unknown) 8610 514 (unknown) 8610 value = 33 = 0x21 = '!' [align=right][color=#000066][此贴子已经被作者于2003-8-6 14:55:23编辑过][/color][/align]
关键词: VxWorks 文件 描述 socket
![](http://m.amcfsurvey.com/uphotos//thumb/avatar.jpg)
The first three file descriptors are predefined by the system and are never reassigned by the system. These three file descriptors (0 - 2) are never returned by creat( ) or open( ). Mappings for the standard file descriptors 0, 1, and 2 are actually maintained outside of the file descriptor table. The file descriptor table starts at index 3 and extends to index NUM_FILES + 2. Global assignments may be changed after system start-up using …………
共8条 1/1
1
跳转至
页
回复
有奖活动 | |
---|---|
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
【有奖活动】智能可穿戴设备AR/VR如何引领科技新潮流! | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
【有奖活动】震撼来袭!这场直播将直击工程师的心灵! |