LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-01-2009, 07:00 AM   #1
BalaMurali46
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Question Linux threads + memory + kernel2.6 + NPTL


we have our project which was running in pentium/Linux 2.4 / Linux Threads with gcc - 2.95 and glibc - 2.1.2
We are now adapting to PowerPC/ Kernel 2.6 / NPTL threads library, gcc 4.1.2 and glibc 2.5.

I face a strange problem,


Thread 1 ----> allocates a memory for a structure A in stack-------> this structure has a pointer filed which is then assigned to an array of another structute of different type B in heap.

The reference/pointer of struct A is passed to thread 2.

Thread 2----->Reads the array of data of structureB.Thread2 Calls another function in thread3 by passing the same pointer of structA.

Thread 3------>Now this thread when trying to read the structureB,Reads only the first array member correctly, when it reads from second till N, it reads from different address from the heap instead of reading from the correct addresses (which I have compared by checking inside thread2 ). So all the data of structureB other than first element in the array are empty


Function call return to thread2, when trying to read the contents of the array of structB, its Ok now.All the data are read correctly.

Problem only in Thread3.

Any possible problems in stack corruption...or thread handling due to differences in LinuxThreads and NPTL or impact of compiler version changes??

Any suggestions will be of much help..

Last edited by BalaMurali46; 10-01-2009 at 11:27 PM.
 
Old 10-01-2009, 05:33 PM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 774

Rep: Reputation: 243Reputation: 243Reputation: 243
Why are you going ahead in threads library. yet majorly backwards in compiler and C library? That alone may cause lots of trouble. I'd recommend up-to-date in all three, especially when dealing with threads.

Last edited by jayjwa; 10-01-2009 at 05:34 PM. Reason: correct spelling error
 
Old 10-01-2009, 11:30 PM   #3
BalaMurali46
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
a mistake in mentioning the compiler versions..it is gcc 4.1.2 and glibc 2.5 for the new kernel version 2.6 and we used gcc - 2.95 and glibc - 2.1.2. for kernel 2.4
Earlier, I just typed it by swapping them.
 
  


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
SIGRT_1 not blocked in Posix Threads (NPTL) gregmb Linux - Software 1 02-27-2019 08:32 PM
POSIX Threads and Dynamic memory allocation using malloc/new perry_mason_i Programming 9 04-03-2009 03:34 PM
Threads and processes with respect to virtual memory jamesaugusty Linux - General 1 08-09-2007 01:18 AM
Any test suite in linux for threads, file descriptors and shared memory segs. Basavaraj Linux - Newbie 2 08-31-2006 08:47 PM
Memory leak when using detached threads incoming429 Programming 1 07-14-2006 09:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:06 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