My system is using Arm cortexa7@1GHz with realtime patchset Linux 4.4.138-rt19 from CIP Community: v4.4.138-cip25-rt19
I has run a prio-preempt.c to verify priority preemption on my system. However I am running an issue: the system only probably runs a number of threads lower than 27 created threads.
About theorical aspect, the ltp app prio-preempt creates 27 worker_threads with different priorities, N busy_threads (N: depend on number of CPU(s), in my case N = 2) with high priority, and master_thread (highest priority).
When deploying the app to the board, threads_running is always lower than 27 while create_fifo_thread(worker_thread,i,...) successfully created 27 worker_thread(s). I ran the same program above on [email protected], the issue didn't happen.
For further vision, I thought the issue might come from Linux RT scheduler unable to waken sleep threads after bmutex lock is released.
Anyone has the same problem to me ? plz share your idea.
Basically, in Linux FULL Preemptive RT system, higher priority threads always preempt lower priority threads to take control of CPU(s). In my case, the issue actually happened on even higher speed processor, I tested on dual [email protected] GHz or quad [email protected]. However, the failed rate was lower much.
Because the issue randomly happened, in cases of failure, all CPU(s) concurrently do the higher priority threads and forget the lower priority threads.
So, I assigned a certain CPU to do a specific thread (high pri).
#define CPU_0 0x01 /* Bind CPU 0 */
#define CPU_1 0x02 /* Bind CPU 1 */
#define CPU_2 0x04 /* Bind CPU 2 */
#define CPU_3 0x08 /* Bind CPU 3 */
...
{
unsigned long cpuset = CPU_0;
if (pthread_setaffinity_np(pthread_self(), sizeof(cpuset), &cpuset) < 0) {
printf("failed to pthread_setaffinity_np\n");
}
}
And yield other CPU(s) to do other jobs (low pri). My system doesn't hang-up any more and probably runs all 27 worker_thread (low-pri threads)