LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-27-2003, 03:21 AM   #1
lamvd
LQ Newbie
 
Registered: Jan 2003
Posts: 10

Rep: Reputation: 0
How to program thread in Linux???


I use KDevelop(2.1) and write a very simple program below:
#include
#include
#include
#include
void *Dosomething(void* arg)
{
char* str = (char*)agr;
printf(“%s”,str);
pthread_exit(NULL);
}

int main(int argc, char *argv[])
{

pthread_t p_thread;
char *agr = “Hello world”;
pthread_create(&p_thread,NULL, Dosomething,(void*)agr);

return EXIT_SUCCESS;
}

But when I debug the program, I have a serious error. I set a break point in a line 'pthread_create(...);' then start debugging. But the compiler notifies me with a message 'gdb message: Program received signal SIGSEGV,Segmentation fault '. The program is so simple that i can't understand the error. So i need some helps to solve this problem. I also need some documents to program with thread in Linux(Unix) environment.

Thanks very much for yours helps.
 
Old 01-27-2003, 06:20 AM   #2
thanhnx
Member
 
Registered: Jan 2003
Posts: 36

Rep: Reputation: 15
web site: Linoleum Linux programming:

http://leapster.org/linoleum/

several links and envolving documents.

NXT
 
Old 01-27-2003, 07:51 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975Reputation: 1975
this is in completely thewrong forum, in future things like this should be in the "Programming" forum. but do NOT ask this again there. someone will probably move it to the correct forum later.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c thread program produces no output kpachopoulos Programming 7 10-14-2005 09:11 PM
program with thread and time melinda_sayang Programming 2 05-28-2005 04:16 AM
fully statically linked posix thread program on PPC mmiglia Linux - Software 0 09-22-2004 07:06 AM
How to program thread in Unix OS?? lamvd Programming 2 01-27-2003 06:14 PM
Thread Program Not Working ssuman Programming 0 04-20-2002 07:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration