Xenomai-forge: pSOS add priority denormalize
PATCH 1/1 Xenomai-forge: pSOS add priority denormalize
Add the psos_task_denormalize_priority() and psos_task_get_priority() functions. Use psos_task_get_priority() to fill oldprio_r in t_setpri().
---
It is necessary to denormalize the oldprio_r in t_setpri(). Else this oldprio_r value can not be used if the user application overrides the normalize function.
include/psos/psos.h +1 -0
@@ -366,6 +366,7 @@ u_long tm_wkwhen(u_long date, u_long ticks);int psos_task_normalize_priority (unsigned long psos_prio); +int psos_task_denormalize_priority (unsigned long core_prio);extern unsigned int psos_long_names;
lib/psos/task.c +22 -1
@@ -236,6 +236,21 @@ int psos_task_normalize_priority(unsignereturn psos_prio; } +/* +* Although default pSOS priorities are mapped 1:1 to SCHED_RT, +* we do still have to use a denormalize function because these +* calls are weak and application code may be override the call +* and implement the mapping differently. +*/ + +__attribute__ ((weak)) +int psos_task_denormalize_priority (unsigned long core_prio) +{ +/* Map a SCHED_RT priority level to a pSOS one. */ +return core_prio; +} + +static int check_task_priority (u_long psos_prio,int *core_prio) {if (psos_prio <1 || psos_prio >255 )/* In theory. */
@@ -246,6 +261,12 @@ static int check_task_priority(u_long psreturn SUCCESS ; } +int psos_task_get_priority (struct psos_task *task) +{ +int prio =threadobj_get_priority (&task->thobj); +return psos_task_denormalize_priority (prio); +} +u_long t_create (const char *name,u_long prio,u_long sstack,u_long ustack,u_long flags,u_long *tid_r) {
@@ -416,7 +437,7 @@ u_long t_setpri(u_long tid, u_long newprif (task ==NULL )return ret; - *oldprio_r =threadobj_get_priority (&task->thobj); + *oldprio_r =psos_task_get_priority (task);if (newprio ==0 ) {/* Only inquires for the task priority. */ put_psos_task (task);
lib/psos/task.h +2 -0
@@ -71,6 +71,8 @@ void put_psos_task(struct psos_task *tasint __ev_send (struct psos_task *task,unsigned long events); +int psos_task_get_priority (struct psos_task *task); +extern struct cluster psos_task_table;#endif /* _PSOS_TASK_H */
Quoted 11 lines · Kim De Mey
Add the
psos_task_denormalize_priority()andpsos_task_get_priority()functions. Usepsos_task_get_priority()to filloldprio_rint_setpri().Signed-off-by Kim De Mey <[email protected]>---
It is necessary to denormalize the
oldprio_rint_setpri(). Else thisoldprio_rvalue can not be used if the user application overrides the normalize function.
Ack.
[snip]
lib/psos/task.h void put_psos_task(struct psos_task *tas · line 75
Quoted 9 lines
lib/psos/task.h +2
-0@@ -71,6 +71,8 @@ void put_psos_task(struct psos_task *tasint __ev_send (struct psos_task *task,unsigned long events); +int psos_task_get_priority (struct psos_task *task); +
Why do you have to introduce this routine in the API?
Signature · 1 line
Philippe.
2013/11/24 Philippe Gerum <[email protected]>:
Quoted 24 lines · Kim De Mey
Quoted 4 lines
Add the
psos_task_denormalize_priority()andpsos_task_get_priority()functions. Usepsos_task_get_priority()to filloldprio_rint_setpri().Quoted 8 lines
Signed-off-by Kim De Mey <[email protected]>---
It is necessary to denormalize the
oldprio_rint_setpri(). Else thisoldprio_rvalue can not be used if the user application overrides the normalize function.Ack.
[snip]
Quoted 5 lines
lib/psos/task.h +0
-0@@ -71,6 +71,8 @@ void put_psos_task(struct psos_task *tas
Quoted 7 lines
lib/psos/task.h void put_psos_task(struct psos_task *tas · line 75
Quoted 4 lines
lib/psos/task.h +2
-0int __ev_send (struct psos_task *task,unsigned long events); +int psos_task_get_priority (struct psos_task *task); +Why do you have to introduce this routine in the API?
Good question, no need for this indeed.
Quoted 3 lines
--
Philippe.