LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 01-23-2009, 04:27 PM   #1
EmbeddedSteve
LQ Newbie
 
Registered: Sep 2006
Posts: 17

Rep: Reputation: 0
Question pthread scheduling in ARM


I have a rather complex and interesting problem here, maybe somebody has run across this before:
I have an application running on an embedded ARM (in the chip we build). I've written a test application that will setup 2 threads (with priority) along with moving the "main" thread to a different priority (> 0). This test application runs just fine, compiled on the board or using cross tools. The Linux kernel is a 2.4.20 flavor.
This same logic is then moved into a library (.so) and I have the "real" application linking this .so. When this "real" application runs, when I get to the point of spawning the first thread (an ISR thread), the thread gets created/spawned, but I never return to the main thread to continue. This is not desired. This first thread down just does a sleep() and then increments a counter and prints it out. It will do this forever (until ^C).
I did find some issues with the pthreads implementation, it was throwing me some errors on some calls that I don't get on 3 other platforms (they are PPC based, same vintage Linux Kernel) and they all work just fine.
We've removed the customer driver's we had to build so as to rule out any interference from them. I get the same results.
For some reason, when running the "real" application, the thread is spawned but does not want to return to the main thread. The Code used is identical to what is in my test code that works.
Today, we rebuilt the .so libraries as .a's and created a static application, since the test code is just built as a stand-alone application, only links to -lrt, -lpthread. In this case, we get the same results, the thread is spawned, but never returns to the main thread.
This is very frustrating and is also critical: if a solution cannot be found, then the project is dead. The use of threading and thread priorities is mandatory for our application.
Has anyone experienced something similar with pthreads on ARM???
Any pointers would be greatly appreciated
TIA
Steve
 
Old 01-24-2009, 05:33 AM   #2
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
Uhm only some pointer: first, not all operating systems are preemptible, so in very rare cases thread switching happens only because of I/O blocking calls (a thread waits for I/O, so other threads can continue). You can try with the pthread sched_yield that "causes the calling thread to relinquish the CPU".
Other thing, the "sleep" system call causes the whole process, not just a thread, to sleep. So, remember this before using it. Use "alarms" as a possible replacement for sleep in thread.
 
Old 02-03-2009, 11:09 PM   #3
Micky_123
LQ Newbie
 
Registered: Dec 2007
Posts: 17

Rep: Reputation: 0
Hi,

What is the scheduling algorithm and what is the scheduling priority for the spawned threads? If you are using Priority based scheduling and priority of the spawned threads is higher than the main, then you may be able to see such kind of behavior...

Micky
 
Old 02-05-2009, 03:05 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,662

Rep: Reputation: 210Reputation: 210Reputation: 210
The question is which pthread implementation you use. The question is especially important in embedded environment, where you can have quite non-standard things. There are some that implementations that do not use system scheduling at all - they do it internally on system calls and pthread_yield(). Try to force the running thread to schedule and see what happens.
 
  


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
Compile the linux2.6.14.1 for arm must ues the arm-linux-gcc-3.4.4? frankyue Linux - Embedded & Single-board computer 2 12-20-2008 07:28 AM
problem in assigning real time scheduling to pthread in linux jasdeep_js Linux - Kernel 1 09-07-2008 01:44 AM
libtest.a uses pthread: user of libtest.a should not link pthread again debulu Programming 2 01-31-2007 09:23 PM
Pthread scheduling... msriram_linux Programming 3 11-21-2004 03:57 PM
scheduling again nautilus_1987 Linux - Software 2 07-04-2003 07:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

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