Regarding giving the priority to a thread
I request you guys to please give me the difference between these two pieces of codes which are used to assign priority to a thread
this piece of code is written in the thread itself
struct sched_param p;
p.sched_priority = 1;
pthread_setschedparam (pthread_self(), SCHED_FIFO, &p);
pthread_make_periodic_np(pthread_self(), gethrtime(), 80000000);
this piece of code is written in the init_module()
struct sched_param sched_param;
sched_param_sched_priority = 1;
pthread_attr_setschedparam (&attr, &sched_param);
pthread_create (&thread, &attr, thread_fn, (void *) 0);
what is the difference between these two codes, which one is better and why? And if they are actually different, where should each one be used?
Waiting for a prompt and lucid reply.