LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-25-2007, 06:11 PM   #1
binutils
Member
 
Registered: Feb 2007
Posts: 59

Rep: Reputation: 15
pthread on mips platform


Hi,

I hava a question about pthread..
I hava a some program which running multithread.
This program runs well on x86 platform, but when it cross-compiled and run on MIPS platform,
after some time, got segmentation fault..

I want to know why this happening.

Any suggestion that will be very appreciated.

PS:
1. i didn't implemented this program, i just take this over.
the person who had given it to me, insist it maybe the bugs is about kernel or device driver not his program fault..

2. personally, i prefer ipc/semaphore or select/poll solution, though i haven't programming so much.

Last edited by binutils; 02-25-2007 at 06:15 PM.
 
Old 02-26-2007, 12:48 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
pthreads is notorious for allowing programmers to create programs which almost all of the time, but then fail inexplicably when some new factor is introduced, such as porting to a different platform. The problem is that issues of timing will make a program look as though it has been written correctly, until the accidents of timing are changed so they are no longer in the user's favor.

Statistically, it is unlikely that the bugs are in the kernel or a device driver. Statistically, it is almost certain that the bugs are in the application you've been asked to maintain.

You have a long, long road ahead. Get Programming with POSIX Threads, by David R. Butenhof (Addison Wesley, publisher). (Do not get the O'Reilly book pthreads Programming; at least the edition I had showed the author's familiarity with the subject, but not a deep-seated understanding of the subtleties.)

Then read the book, at least almost all of it. Let it get under your skin. Write a few toy programs which deliberately illustrate the problems that pthreads programming can present.

Then read the application you've been handed. Every line of it.

If you enjoy a challenge, this situation will make you very happy.

Hope this helps.
 
Old 02-26-2007, 06:56 PM   #3
binutils
Member
 
Registered: Feb 2007
Posts: 59

Original Poster
Rep: Reputation: 15
Thanks for your advice.

So it seems the timing in MIPS(or pthread implementation of glibc on MIPS) different to x86's.

Oh, i forgot to mention one more thing, the program has one bug on x86.
I can't tell you more, but, this person implemented it his own way, regardless of existen good open source which is in good quality..

And about the book, actually, i have read the book a little (Programming with POSIX Threads)..
I don't like it, it smell like devil's advocate..

I believe in ESR's "the art of unix programming"

PS: i tried to read the book twice(Programming with POSIX Threads), and i gave up.

Last edited by binutils; 02-26-2007 at 07:17 PM.
 
Old 02-27-2007, 08:44 AM   #4
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
The book has far more wisdom than meets the eye. Most of the "devil's advocate" stuff is warnings about stuff that can bite you. I found one misprint in the book (a bug in one of his chunks of sample code), but other than that, everything I've read in the book is grounded in truth. Ignoring something in the book has the potential to bite you.

But if the book doesn't appeal to you, then do this:

When you encounter a bug which seems impossible to fix, and it seems thread related or timing related, dip into the book until you find the answer to the problem.

In the long run, it will take longer to clean up the code this way; a shorter way would be to digest the book thoroughly and then read all the code. But I sense that this longer way sits with you a little better.

Good luck.
 
  


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
libtest.a uses pthread: user of libtest.a should not link pthread again debulu Programming 2 01-31-2007 09:23 PM
LXer: Platform Expands Platform Open Cluster Stack With First AMD-Based ... LXer Syndicated Linux News 0 11-13-2006 06:54 PM
LXer: CodeSourcery Joins MIPS(R) Alliance Program and Delivers GNU/Linux Prelinker for MIPS-Based(TM) Processors LXer Syndicated Linux News 0 10-31-2006 07:54 PM
how to run programmes made for windows platform in linux platform... compugeek2006 Linux - Software 1 06-26-2006 09:34 PM
How can i send message from Linux platform to Windows platform linuxeagle Linux - Networking 1 02-17-2004 12:35 AM

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

All times are GMT -5. The time now is 07:10 AM.

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