Threads = SIGSEV ?


 
Thread Tools Search this Thread
Top Forums Programming Threads = SIGSEV ?
# 1  
Old 12-04-2006
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 ?? ()
# 2  
Old 12-05-2006
try this one
Code:
int thc;
//pthread_create(PID,thread arguments,Process begin,arguments)
pthread_create(&thc, NULL,newthread(),NULL);

# 3  
Old 12-05-2006
ohh

really thx Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Threads help

Hello! I started studying studying about POSIX Threads a few days ago... so I am a little confused and I would appreciate some help! I isolated this code... and I wonder if I could use threads in it! #include <unistd.h> #endif #include <math.h> //#include "main.h" #include <sys/time.h>... (1 Reply)
Discussion started by: smurf2
1 Replies

2. UNIX for Advanced & Expert Users

Threads and Threads Count ?

Hi all, How can I get the list of all Threads and the Total count of threads under a particular process ? Do suggest !! Awaiting for the replies !! Thanks Varun:b: (2 Replies)
Discussion started by: varungupta
2 Replies

3. UNIX for Advanced & Expert Users

How many threads do I use ?

Hi, I have a program that has two types of threads: 1) Reader threads 2) Worker Threads Readers: Their only job is to read files. They just read data from the files and put them into a buffer. They are obviously I/O intensive. Workers: These are CPU intensive. They do some computation... (5 Replies)
Discussion started by: the_learner
5 Replies

4. Solaris

threads

Hi all! 1)Is there a way to write a program that will work on both solaris and intel based machines. 2)How can I achive this for a program that creates and synchronizes three threads. Thank you. vij. (3 Replies)
Discussion started by: vijlak
3 Replies

5. HP-UX

Threads and Signals

I want to handle signals in a process that involves lots of threads. Now I do know that there should be a dedicated thread that will actually be traping signals and then these signals will be ditributed to actual threads. My question is...in case a signals has been generated by a kernel for the... (0 Replies)
Discussion started by: ripunjay
0 Replies

6. UNIX for Dummies Questions & Answers

threads

i am tring to sort lots of data thats in many columns by just one column but, if I use sort +16 inputfile the column fluctuates because some of the rows have spaces etc within the text, so the end result is just a mess as it jumps around the columns depending whether it has spaces or not ....ie... (2 Replies)
Discussion started by: Gerry405
2 Replies

7. Post Here to Contact Site Administrators and Moderators

Long threads?

Greetings, I'm relatively new-comer to these forums and have a Q to the mods. Just wondering what's the policy regarding the long running threads where they tend to go say over 30 posts and they become "troubleshooting" threads rather than being "educational" and/or "hinting" threads? ... (4 Replies)
Discussion started by: vgersh99
4 Replies

8. Post Here to Contact Site Administrators and Moderators

old threads

Neo, if I have an old thread that is a few months old, and a few pages back in the forum it was posted in, is it ok to 'bump' it back to the front? or, would you rather i deleted the old thread, and just create a new one? btw the thread has no replies. (2 Replies)
Discussion started by: norsk hedensk
2 Replies
Login or Register to Ask a Question