1. Thread priority scheduling across linux kernels RH9.0 and RH 7.2. - Linux
2. Thread Priority ?? in RealTime Scheduling(pTreads)
Hi everybody,
Could you help me please.....
Field : i am tried to set a thread priority with SCHED_FIFO and
SCHED_RR.
Suitutaion : My application program create three threads, one with
SCHED_FIFO ,another with SCHED_FIFO
and last SCHED_OTHER..... all three threads are in
infinite loop.
i use to set priorities for each thread 99**,1,0
repectively.(success return in pthread_setschedparam)
** Note : pthread higher value
has higher priority)
i used to print microseconds repeatedly in
threads......... but all threads executing same time......
Question:
what will be the execution flow of the above
suitution.....
will first thread (has higher priority) will
entirely occupies the CPU or give CPU to othres ,if yes how ???
3. set thread priority of threads produced with kernel_thread() in kernel mode - Embedded Linux
4. Scheduling a higher priority thread returning from clock_nanosleep()
6. Thread Priority setting for SCHED_RR and SCHED_FIFO does not work as expected on Linux Kernel 2.6
Hi,
I wrote one simple program to test the functionality of the policy for
SCHED_RR
and SCHED_FIFO one linux kernel 2.6. I created two threads, one with the
priority
42 and the other with the priority 41.The two threads execute the same
function, which just
prints "printf(....") statements all the time.
In theory, only when the first has finish its execution, the second could
get
the chance to run. But unfortunately,the result is very confusing: the
second
can run even if the first thread is still running.
I complied the program as "gcc test.c -lpthread"
Below is my codes:
===============================================================
#include <pthread.h>
#include <stdio.h>
void* dowork(void* idp)
{
int i;
int *my_id = (int*) idp;
printf("Thread %d is starting up\n", *my_id);
sleep(2);
while(1)
{
printf("Thread %d is doing work. \n", *my_id);
}
}
int main (int argc, char* argv[])
{
int i;
pthread_t threads[2];
int thread_ids[2] = {0, 1};
pthread_attr_t attr_high, attr_low;
struct sched_param param_high, param_low;
pthread_attr_init(&attr_high);
pthread_attr_init(&attr_low);
pthread_attr_setinheritsched(&attr_high, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setinheritsched(&attr_low, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setdetachstate(&attr_high, PTHREAD_CREATE_JOINABLE);
pthread_attr_setdetachstate(&attr_low, PTHREAD_CREATE_JOINABLE);
/* set thread priority 42 and scheduling policy SCHED_RR for high
thread */
param_high.sched_priority = 42;
pthread_attr_setschedparam(&attr_high, ¶m);
pthread_attr_setschedpolicy(&attr_high, SCHED_RR);
pthread_create(&threads[0], &attr_high, dowork, &thread_ids[0]);
/* set thread priority 41 and scheduling policy SCHED_RR for high
thread */
param_high.sched_priority = 41;
pthread_attr_setschedparam(&attr_low, ¶m);
pthread_attr_setschedpolicy(&attr_low, SCHED_RR);
pthread_create(&threads[1], &attr_low, dowork, &thread_ids[1]);
for (i = 0; i < 2; i++)
{
pthread_join(threads[i], NULL);
}
printf ("Main(): Waited on 2 threads. Done.\n");
/* Clean up and exit */
pthread_attr_destroy(&attr_high);
pthread_attr_destroy(&attr_low);
pthread_exit(NULL);
}