The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Threads and Threads Count ? varungupta UNIX for Advanced & Expert Users 2 03-21-2008 06:23 PM
How many threads do I use ? the_learner UNIX for Advanced & Expert Users 5 07-17-2007 02:31 PM
threads vijlak SUN Solaris 3 01-29-2007 04:55 PM
old threads norsk hedensk Post Here to Contact Site Administrators and Moderators 2 06-03-2003 02:16 PM
nfs threads i2admin UNIX for Advanced & Expert Users 1 03-06-2003 08:28 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 12-04-2006
sendai's Avatar
Registered User
 

Join Date: Dec 2006
Location: Brasil
Posts: 18
Threads = SIGSEV ?

I'm studing about thread and sometimes when I run this code i receive a SIGSEV
someone have some idea of wath is occuring?

gcc thread.c -o thread -pthread
Code:
#include <stdio.h>
#include <pthread.h>

int xip=0;
int main(){
int *thc;

//pthread_create(PID,thread arguments,Process begin,arguments)
pthread_create(&thc, NULL,newthread(),NULL);
printf("World\n");
exit(0);
} 

int *newthread(){
printf("Hello ");
return(0);
}
the return is

sendai@slack:~$ ./thread
Hello World
Segmentation fault
sendai@slack:~$ ./thread
Hello World
sendai@slack:~$ ./thread
Hello World
sendai@slack:~$ gdb thread
>run
Starting program: /home/sendai/thread
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 2412)]
[New Thread 32769 (LWP 2414)]
[New Thread 16386 (LWP 2415)]
Hello World

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16386 (LWP 2415)]
0x00000000 in ?? ()
Reply With Quote
Forum Sponsor
  #2  
Old 12-04-2006
andryk's Avatar
Registered User
 

Join Date: Sep 2003
Posts: 448
try this one
Code:
int thc;
//pthread_create(PID,thread arguments,Process begin,arguments)
pthread_create(&thc, NULL,newthread(),NULL);
Reply With Quote
  #3  
Old 12-05-2006
sendai's Avatar
Registered User
 

Join Date: Dec 2006
Location: Brasil
Posts: 18
ohh

really thx
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0