Linux 板


LINE

※ [本文转录自 C_and_CPP 看板 #1JOU9vFQ ] 作者: BIAO (超越自己) 看板: C_and_CPP 标题: [问题] Linux C多执行绪的疑问!? 时间: Thu May 1 13:58:15 2014 开发平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux ------------------------------- 各位板友大家好, 目前小弟有个程式,内有A、B两个thread,共用某个副程式, 其中A thread固定时间会执行该副程式, 另个B thread则随机等候外部命令,接收外部命令後执行该副程式。 此程式在Linux内执行, 可有时候会自己中断执行, 请问这是因为没使用mutex, 发生冲突导致程式结束吗!? 另想请问板友... 有什麽因素导致程式执行时,会自动结束呢!? 还请板友不吝赐教,谢谢..XD -- --



※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.124.42.70
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1398923897.A.3DA.html ※ 编辑: BIAO (140.124.42.70), 05/01/2014 14:15:52
1F:推 acake:两个thread有需要用mutex同步吗? 05/01 20:10
2F:推 RouterHsieh:没有产生core dump吗? 05/01 22:04
3F:→ RouterHsieh:话说这问题跟本板没啥关系..转去LinuxDev比较恰当吧 05/01 22:05
4F:→ BIAO:谢谢两位板友的回覆,我转到Linux.. XD 05/02 11:30



※ 发信站: 批踢踢实业坊(ptt.cc)
※ 转录者: BIAO (140.124.42.70), 05/02/2014 11:30:46
5F:→ bitlife:你自少要知道结束原因,程式自己正常exit,一般signal 或 05/02 11:53
6F:→ bitlife:SIGSEGV 05/02 11:53
7F:→ BIAO:我的程式是设定...无穷回圈 二个thread都是.. 所以才纳闷XD 05/02 13:00
8F:→ bitlife:所以我说要先找出原因,你可以先用交谈式shell把程式丢背景 05/02 13:32
9F:→ bitlife:shell不要登出,等程式结束,shell会显示程式怎麽结束的 05/02 13:33
10F:→ BIAO:谢谢b大.. 没用过shell!不过现在明白处理方式了,感谢您~~~ 05/02 13:50
11F:→ bitlife:你用linux但没用过shell?这...? 那你怎麽跑程式的? 05/02 14:50
回b大的话... 我都是用vim编辑C code, 用gcc编译後,直接用sudo ./执行程式.. 偶尔加个&来背景执行.. XD ※ 编辑: BIAO (140.124.42.70), 05/02/2014 15:04:57
12F:→ bitlife:你sudo那行命令应该就是在交谈式shell下执行的 05/02 15:10
13F:→ bitlife:执行 echo $SHELL 就知道你目前是用什麽shell 05/02 15:11
14F:→ BIAO:(!!!) 原来是这个样子..谢谢b大 :D 05/02 15:16
15F:→ BIAO:目前已物色到一本不错的书..准备入手!! 05/02 15:20
16F:→ BIAO:我是用bash~~~ 05/02 16:16
目前已经完全懂b大的意思.. 我的确是在interactive mode执行程式, 不过就算执行没加上&,程序自行结束时也没有产生程序如何结束.. 我是使用Ubuntu Linux,目前在寻找产生Core dump的方法XD C语言程序是无穷回圈,二个thread都是.. ※ 编辑: BIAO (140.124.42.70), 05/02/2014 21:25:13 ※ 编辑: BIAO (140.124.42.70), 05/02/2014 21:26:33
17F:→ kdjf:gcc -g (debug), 加上gdb试试看吧 05/02 21:51
18F:→ lantw44:$SHELL 是登入的时候设定的,如果自己开其他 shell 05/02 22:46
19F:→ lantw44:不会跟着变 05/02 22:46
20F:→ bitlife:楼上,我是看原po连shell是什麽都不知道,所以才叫他看目前 05/02 23:21
21F:→ bitlife:是什麽shell XD 05/02 23:21
22F:→ bitlife:不过你这补充说明对原po还是有用就是了 05/02 23:23
感谢大家的回覆,参照k大做法, 采用gcc -o -g -DDEBUG modbus+MySQL+Control26 modbus+MySQL+Control26.c -I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lpthread, 得到了许多资讯.. ------------------------------------- modbus+MySQL+Control26: In function `_fini': crtstuff.c:(.fini+0x0): multiple definition of `_fini' /usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.o:(.fini+0x0): first defined here modbus+MySQL+Control26: In function `__data_start': crtstuff.c:(.data+0x0): multiple definition of `__data_start' /usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o:(.data+0x0): first defined here modbus+MySQL+Control26: In function `__data_start': crtstuff.c:(.data+0x4): multiple definition of `__dso_handle' /usr/lib/gcc/arm-linux-gnueabihf/4.6/crtbegin.o:(.data+0x0): first defined here modbus+MySQL+Control26:(.rodata+0x0): multiple definition of `_IO_stdin_used' /usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o:(.rodata.cst4+0x0): first defined here modbus+MySQL+Control26: In function `_start': crtstuff.c:(.text+0x0): multiple definition of `_start' /usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o:(.text+0x0): first defined here modbus+MySQL+Control26: In function `_init': crtstuff.c:(.init+0x0): multiple definition of `_init' /usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.o:(.init+0x0): first defined here /tmp/ccj4NCbh.o:(.bss+0x0): multiple definition of `data_lock' modbus+MySQL+Control26:(.bss+0x10): first defined here /tmp/ccj4NCbh.o: In function `sock_server_thread': modbus+MySQL+Control26.c:(.text+0x0): multiple definition of `sock_server_thread' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:38: first defined here /tmp/ccj4NCbh.o: In function `order_dec': modbus+MySQL+Control26.c:(.text+0x3f4): multiple definition of `order_dec' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:154: first defined here /tmp/ccj4NCbh.o: In function `control': modbus+MySQL+Control26.c:(.text+0x7f4): multiple definition of `control' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:248: first defined here /tmp/ccj4NCbh.o: In function `status': modbus+MySQL+Control26.c:(.text+0x2098): multiple definition of `status' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:697: first defined here /tmp/ccj4NCbh.o: In function `info': modbus+MySQL+Control26.c:(.text+0x1204): multiple definition of `info' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:469: first defined here /tmp/ccj4NCbh.o: In function `main': modbus+MySQL+Control26.c:(.text+0x378): multiple definition of `main' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:132: first defined here /tmp/ccj4NCbh.o: In function `modbustcp': modbus+MySQL+Control26.c:(.text+0x2c20): multiple definition of `modbustcp' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:898: first defined here /tmp/ccj4NCbh.o: In function `modbusrtu': modbus+MySQL+Control26.c:(.text+0x2f1c): multiple definition of `modbusrtu' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:1004: first defined here /tmp/ccj4NCbh.o: In function `info_insert': modbus+MySQL+Control26.c:(.text+0x1c88): multiple definition of `info_insert' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:636: first defined here /tmp/ccj4NCbh.o: In function `cost_power': modbus+MySQL+Control26.c:(.text+0x1e1c): multiple definition of `cost_power' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:660: first defined here /tmp/ccj4NCbh.o: In function `status_insert': modbus+MySQL+Control26.c:(.text+0x2844): multiple definition of `status_insert' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:839: first defined here /tmp/ccj4NCbh.o: In function `crc16': modbus+MySQL+Control26.c:(.text+0x321c): multiple definition of `crc16' modbus+MySQL+Control26:/home/ubuntu/C-practice/Test/modbus+MySQL+Control26.c:1114: first defined here collect2: ld returned 1 exit status ubuntu@localhost:~/C-practice/Test$ ------------------------------------- 这些资讯是没加上-g不会出现的..XD ※ 编辑: BIAO (140.124.42.70), 05/03/2014 13:18:36







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:BuyTogether站内搜寻

TOP