LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


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

Rep: Reputation: 0
Question How to program thread in Unix OS??


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, 07:50 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
http://www.linuxquestions.org/questi...threadid=42910

do not ask the same question more than once, for any reason.
 
Old 01-27-2003, 06:14 PM   #3
finegan
LQ Guru
 
Registered: Aug 2001
Location: Dublin, Ireland
Distribution: Slackware
Posts: 5,700

Rep: Reputation: 72
Moved, much more appropriate in Programming, also Crabby if you see this one, you might want to merge in the double post from Newbie.

Cheers,

Finegan
 
  


Reply



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
How to program under Linux/Unix platform Igor007 AIX 3 08-20-2004 01:00 PM
How to program thread in Linux??? lamvd Linux - Newbie 2 01-27-2003 07:51 AM
Thread Program Not Working ssuman Programming 0 04-20-2002 07:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:57 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
Open Source Consulting | Domain Registration