Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linuxÏß³Ì(pthread)±à³ÌÖеÄsegmentation fault£¡£¡


linuxÏß³Ì(pthread)±à³ÌÖеÄsegmentation fault£¡£¡
Posted on ÐÇÆÚÎå, 3ÔÂ 27th, 2009 at 10:28 ÏÂÎç
Ô´ÎÄÀ´×Ôhttp://www.isongzi.com/2009/03/27/pthread-segmentation-fault/
¼Ìsocket bad addres ´íÎóÖ®ºó£¬ÔÚ´´½¨Ï̡߳¾pthread_create()¡¿µÄʱºòÓÖ³öÏÖÁË segmentation fault¡£
´íÎóÓï¾äÈçÏ£º
pthread_create(&dec_tid,NULL, (void *)&encode, (void *)&cmd);
encode ÉùÃ÷ÈçÏ£º
int encode(void *arg);
¿ªÊ¼ÎÒÏëµÄÊÇ£¬»á²»»áÊÇencodeÇ°Ãæ²»ÓüÓ&ÄØ£¿°´ÕÕÉùÃ÷¶¨Ò壺
pthread_create(&tid, &attr, (void *)myfunction, myarg);
µÚÈý¸ö²ÎÊý¾ÍÊǺ¯ÊýÃû¶øÒÑ£¬ÊÇΪÁ˱íÃ÷Ï̺߳¯ÊýµÄÈë¿ÚµØÖ·¡£µ«ÊÇ£¬¿´µÄfreescaleÌṩµÄ²Î¿¼³ÌÐòÖÐÓÐÔ´ÂëÊÇÕâÑùµÄ£º
pthread_create(&sigtid, NULL, (void *)&signal_thread, NULL);
Ò²¾ÍÊÇ˵£¬¿ÉÒ԰ѵÚÈý¸ö²ÎÊýÒ²¼´º¯ÊýÃûÇ°Ãæ¼ÓÉÏ&£¬Á½¸öЧ¹ûÒ»Ñù¡£ÎªÁ˼ìÑéµ½µ×ʲôµØ·½´íÎ󣬻¹ÊǸÄÁËһϣº
pthread_create(&dec_tid,NULL, (void *)encode, (void *)&cmd);
°ÑencodeÇ°Ãæ µÄ&È¥µô£¬µ«ÊÇÒÀÈ»segmentation fault.¡£
ÍøÉÏÕÒÁËһϣ¬Ô­ÒòÔÚÓÚµ÷ÊÔµÄʱºòû¼Ó -lpthread!ÏëÒª±àÒë¶àÏ̵߳ijÌÐò£¬±ØÐëÈçϱàÒ룺
gcc -o test  -lpthread test.c£¬
ÒòΪÏ߳̿ⲻÊÇÄÚºË×Ô´øµÄ£¬ÒªÏÔʽ˵Ã÷¡£ÎÊÌâÊÇ£¬ÎªÊ²Ã´GCCÔÚ±àÒëµÄʱºò²»±¨´íÄØ£¿
Õâ¸öÎÊÌâ±È½ÏÓÐÄѶȡ£ºÃÁË£¬Ô­ÒòÕÒµ½ÁË£¬Ôõô½â¾ö£¿Makefile ÎļþÈçÏ£º
#This Makefile is from http://isongzi.com which is to make send.out
CC=$(CROSS_COMPILE)gcc
LINK=$(CROSS_COMPILE)gcc
CROSS_COMPILE=arm-926ejs-linux-
OBJ = main.o \
enc.o \
capture.o \
fb.o \
socket.o \
OBJDIR=./bin
LIBNAME = libvpu.a
LIBDIR = ./lib/
# list of platforms which want this test case
INCLUDE_LIST:=IMX27ADS IMX31ADS MXC30031ADS IMX27MDK27V0
TARGET = send.out
all: $(TARGET) $(TARGET1)
$(TARGET): $(LIBDIR)$(LIBNAME) $(OBJ)
$(LINK) -L . -lpthread -o $(TARGET) $(OBJ) $(LIBNAME)
mkdir -p $(OBJDIR)
mv $(TARGET) $(OBJDIR)
mv $(LIBNAME) $(OBJDIR)
%.o: %.c
$(CC) -Wall -O2 -I $(LIBDIR) -c $^ -o $@
$(LIBDIR)$(LIBNAME):
make -C $(LIBDIR)
mv $(LIBDIR)$(LIBNAME) .
.PHONY: clean
clean:
rm -f $(OBJDIR)/$(TARGET) $(OBJ) $(LIBNAME)
Ô­À´


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌṩÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

ʵսLinux Bluetooth±à³Ì (Æß) SDPЭÒé

Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖЭÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀЭÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......

Linux ÖÐÎÄÂÒÂë½â¾ö

ÐÞ¸Ä linux ϵͳ/ect/profile Îļþ
ÔÚ×îºóÃæ¼Ó
export LC_ALL="zh_CN.GB18030"
ÐÞ¸Ä /etc/sysconfig/i18nÎļþ
LANG="zh_CN.GB18030"
LANGUAGE="zh_CN.GB18030:zh_CN.GB2312:zh_CN"
SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"
SYSFONT="lat0-sun16"
SYSFONTACM="iso01"
ÕâÑù¾Í¿ÉÒÔ½â¾ölinuxÏÂÖÐÎÄ ......

Linux ÖÐÎÄ×ÖÌåÂÒÂëÐÞ¸Ä i18n Îļþ

ÕâôÄã¾ÍÐèÒªÐÞ¸ÄÒ»ÏÂ×Ö·û±àÂëµÄÅäÖá£
# cd /etc/sysconfig
# vi i18n
-------------------ÎļþÄÚÈÝ------------------
LANG="zh_CN.GB18030"
SUPPORTED="zh_CN.UTF-8:zh_CN:zh:en_US.UTF-8:en_US:en:zh_CN.GB18030"
SYSFONT="latarcyrheb-sun16"
-----------------------£ºqw ±£´æÍ ......

Ïê½âLinuxÄÚºË֮˫ÏòÑ­»·Á´±í(ת)

ÕªÒª: ±¾ÎÄÏê½âÁËÄÚºËÖÐÃæÏò¶ÔÏóµÄlist½á¹¹µÄÔ­Àí£¬ÒÔ¼°ÈçºÎÒÔlistΪÄÚǶ¶ÔÏóÀ´¹¹Ôì×Ô¼ºµÄÁ´±í½á¹¹£¬ÈçºÎ´ÓÄÚǶlist¶ÔÏó»ñµÃ×Ô¶¨ÒåµÄ¶ÔÏóÖ¸Õ룻̽ÌÖÁ˸÷ÖÖºê»òÕߺ¯ÊýµÄÏêϸʹÓ÷½·¨¼°ÔõÑùÒÔͨÓÃlist½á¹¹À´²Ù×÷×Ô¶¨Òå¶ÔÏó¡£
¹Ø¼ü×Ö:Ë«ÏòÑ­»·Á´±í£¬list£¬list_entry£¬typeof£¬containerof£¬list_for_each,list_for_each ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ