亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費注冊 查看新帖 |

Chinaunix

  平臺 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 3726 | 回復(fù): 3
打印 上一主題 下一主題

[C] 求助:fgets 讀文件死鎖! [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報告]
發(fā)表于 2013-10-14 16:16 |只看該作者 |倒序瀏覽
問題:難道fgets函數(shù)也死鎖,系統(tǒng)上線后出現(xiàn)過幾次這類問題。 暫未解決,只能kill掉讀取進程。

環(huán)境:HP-UX 安騰 64。
數(shù)據(jù)文件:放在共享存儲上,不在本機硬盤上。
描述:兩個并發(fā)進程進入文件拆分函數(shù),讀取同一待拆分文件,然后就沒有下文,僵在里面。
錯誤跟蹤日志如下:

--進程A,GDB堆棧信息
xxxx@/home/db/xxxx> gdb xxxxFileLoad 20166
HP gdb 6.2 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2011 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Attaching to program: /home/db/xxxx/xxxxbatch/bin/xxxxFileLoad, process 20166

warning: The shared libraries were not privately mapped; setting a
breakpoint in a shared library will not work until you rerun the program;
stepping over longjmp calls will not work as expected.
Please set the kernel variable "shlib_debug_enable" to 1 to enable the shared library debugging

warning: Load module /home/db/oracle/product/10.2.0/lib/libnnz10.so has been stripped.  
Debugging information is not available.

0xc00000000054a490:0 in _read_sys+0x30 () from /usr/lib/hpux64/libc.so.1
(gdb) bt
#0  0xc00000000054a490:0 in _read_sys+0x30 () from /usr/lib/hpux64/libc.so.1
#1  0xc00000000055ed80:0 in read+0xe0 () from /usr/lib/hpux64/libc.so.1
#2  0xc000000000527a20:0 in _filbuf+0x190 () from /usr/lib/hpux64/libc.so.1
#3  0xc00000000053a0d0:0 in __fgets_unlocked+0x1f0 () from /usr/lib/hpux64/libc.so.1
#4  0xc00000000053a3e0:0 in fgets+0x140 () from /usr/lib/hpux64/libc.so.1
#5  0x4000000000030320:0 in g_GetFSegment () at p_file.c:301  文件拆分函數(shù):這一行就是 fgets(),其讀取緩存大小為一次讀取 400K。
#6  0x4000000000006130:0 in InsxxxxFile () at xxxxFileLoad.pc:1060
#7  0x4000000000005380:0 in main () at xxxxFileLoad.pc:107
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /home/db/xxxx/xxxxbatch/bin/xxxxFileLoad, process 20166


--進程B,GDB堆棧信息
xxxx@/home/db/xxxx> gdb xxxxFileLoad 20167
HP gdb 6.2 for HP Itanium (32 or 64 bit) and target HP-UX 11iv2 and 11iv3.
Copyright 1986 - 2011 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 6.2 (based on GDB) is covered by the
GNU General Public License. Type "show copying" to see the conditions to
change it and/or distribute copies. Type "show warranty" for warranty/support.
..
Attaching to program: /home/db/xxxx/xxxxbatch/bin/xxxxFileLoad, process 20167

warning: The shared libraries were not privately mapped; setting a
breakpoint in a shared library will not work until you rerun the program;
stepping over longjmp calls will not work as expected.
Please set the kernel variable "shlib_debug_enable" to 1 to enable the shared library debugging

warning: Load module /home/db/oracle/product/10.2.0/lib/libnnz10.so has been stripped.  
Debugging information is not available.

0xc00000000054a490:0 in _read_sys+0x30 () from /usr/lib/hpux64/libc.so.1
(gdb) bt
#0  0xc00000000054a490:0 in _read_sys+0x30 () from /usr/lib/hpux64/libc.so.1
#1  0xc00000000055ed80:0 in read+0xe0 () from /usr/lib/hpux64/libc.so.1
#2  0xc000000000527a20:0 in _filbuf+0x190 () from /usr/lib/hpux64/libc.so.1
#3  0xc00000000053a0d0:0 in __fgets_unlocked+0x1f0 () from /usr/lib/hpux64/libc.so.1
#4  0xc00000000053a3e0:0 in fgets+0x140 () from /usr/lib/hpux64/libc.so.1
#5  0x4000000000030320:0 in g_GetFSegment () at p_file.c:301 文件拆分函數(shù):這一行就是 fgets(),其讀取緩存大小為一次讀取 400K。
#6  0x4000000000006130:0 in InsxxxxFile () at xxxxFileLoad.pc:1060
#7  0x4000000000005380:0 in main () at xxxxFileLoad.pc:107
(gdb) quit
The program is running.  Quit anyway (and detach it)? (y or n) y
Detaching from program: /home/db/xxxx/xxxxbatch/bin/xxxxFileLoad, process 20167

請教一下可能是什么原因?qū)е麓祟悊栴}隨機產(chǎn)生。

論壇徽章:
1
2015年辭舊歲徽章
日期:2015-03-03 16:54:15
2 [報告]
發(fā)表于 2013-10-15 12:53 |只看該作者
man手冊里說明了可以用*_unlocked()來做非阻塞操作。

論壇徽章:
0
3 [報告]
發(fā)表于 2013-10-16 08:59 |只看該作者
因為fgets的讀操作(read系統(tǒng)調(diào)用)是在網(wǎng)絡(luò)設(shè)備上讀取文件導(dǎo)致永遠阻塞(就是死鎖)。

APUE 14.2中描述
  1. 低速系統(tǒng)調(diào)用是可能會使進程永遠阻塞的一類系統(tǒng)調(diào)用,它們包括下列調(diào)用:
  2.   * 如果某些文件類型(例如管道、終端設(shè)備和[color=Red]網(wǎng)絡(luò)設(shè)備[/color])的數(shù)據(jù)并不存在,則讀操作可能會使調(diào)用者永遠阻塞。
  3.   * 。。。。
復(fù)制代碼
你的系統(tǒng)使用的共享存儲,它不是本地文件系統(tǒng),所以它屬于低速設(shè)備。

另外,APUE 中還說
  1. 我們也曾說過,雖然讀、寫磁盤文件會使調(diào)用者在短暫時間內(nèi)阻塞,但并不能將和磁盤I/O有關(guān)的系統(tǒng)調(diào)用視為“低速”。
復(fù)制代碼
這一點我不能給出進一步解釋,為何磁盤文件不屬于“低速”,它是否會永遠阻塞,我沒有找到明確的答案。
望得到指點。。。

論壇徽章:
0
4 [報告]
發(fā)表于 2013-10-16 13:30 |只看該作者
意思是:網(wǎng)絡(luò)設(shè)備可能在某一時點失效,從而使讀取發(fā)生死鎖,可以采用 fgets_unlocked 來規(guī)避?
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報專區(qū)
中國互聯(lián)網(wǎng)協(xié)會會員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP