1

According to my question here I would like to use SCHED_RR with pthread_setschedparam for my threads in a Linux application. However, this has effects even on kernel modules which I currently cannot solve.

I have found http://www.icir.org/gregor/tools/pthread-scheduling.html which says that I could create my threads with PTHREAD_SCOPE_PROCESS attribute, but I haven't found further information on this.

Will this work with (Angstrom) Linux, kernel version2.6.32? (How) will this affect the way my process competes with other processes? Would it be the way to have my processes compete with real time scheduling but other processes would not be affected?

(As I am using boost threads I cannot simply try this...)

Community
  • 1
  • 1
Philipp
  • 11,549
  • 8
  • 66
  • 126

1 Answers1

3

Threads created with PTHREAD_SCOPE_PROCESS will share the same kernel thread ( http://lists.freebsd.org/pipermail/freebsd-threads/2006-August/003674.html )

However, SCHED_RR must be run under a root-privileged process.

Round-Robin; threads whose contention scope is system (PTHREAD_SCOPE_SYSTEM) are in real-time (RT) scheduling class if the calling process has an effective user id of 0. These threads, if not preempted by a higher priority thread, and if they do not yield or block, will execute for a time period determined by the system. SCHED_RR for threads that have a contention scope of process (PTHREAD_SCOPE_PROCESS) or whose calling process does not have an effective user id of 0 is based on the TS scheduling class.

However, basing on your linked problem I think you are facing a deeper issue. Have you tried setting your kernel to be more "preemptive"? Preemption should allow the kernel to forcibly schedule out of running your process allowing for more responsive running of some kernel parts. This shouldn't affect IRQs though, maybe something disabled your IRQs?

Another thing I am thinking about is maybe that you are not fetching your SPI data fast enough and the buffor for your data in the kernel becomes full and hence the data loss. Try increasing those buffers also.

RushPL
  • 4,732
  • 1
  • 34
  • 44
  • Thanks for the documentation extract. My process does run as root. But what does the sentence in bold mean for me, then? It says that the if I used PTHREAD_SCOPE_PROCESS it will use the TS scheduling, right? What effect does the priority have then? – Philipp Oct 07 '11 at 10:23
  • It means that your SCHED_RR will not work for PTHREAD_SCOPE_PROCESS, it will use whatever Time Sharing shedulling you have by default. – RushPL Oct 07 '11 at 10:39