共8条
1/1 1 跳转至页
VxWorks的文件描述符bug!?

在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

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电子工程师创研计划】技术变现通道已开启~ | |
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】STM32的硬件通讯调试过程的“坑”被打赏50分 | |
【我踩过的那些坑】晶振使用的问题被打赏100分 | |
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 |