Skip to content

Commit ea6e61f

Browse files
committed
Fix priority check for LXRT
Cherry-Pick from 2.9 branch
1 parent 46c14f9 commit ea6e61f

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/rtapi/rtapi_uspace.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ struct RtapiApp
7575
virtual int prio_lowest() const;
7676
int prio_higher_delta() const;
7777
int prio_bound(int prio) const;
78+
bool prio_check(int prio) const;
7879
int prio_next_higher(int prio) const;
7980
int prio_next_lower(int prio) const;
8081
long clock_set_period(long int period_nsec);

src/rtapi/uspace_rtapi_app.cc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,14 @@ int RtapiApp::prio_bound(int prio) const {
921921
return prio;
922922
}
923923

924+
bool RtapiApp::prio_check(int prio) const {
925+
if(rtapi_prio_highest() > rtapi_prio_lowest()) {
926+
return (prio <= rtapi_prio_highest()) && (prio >= rtapi_prio_lowest());
927+
} else {
928+
return (prio <= rtapi_prio_lowest()) && (prio >= rtapi_prio_highest());
929+
}
930+
}
931+
924932
int RtapiApp::prio_next_higher(int prio) const
925933
{
926934
prio = prio_bound(prio);
@@ -951,8 +959,10 @@ int RtapiApp::allocate_task_id()
951959
int RtapiApp::task_new(void (*taskcode) (void*), void *arg,
952960
int prio, int owner, unsigned long int stacksize, int uses_fp) {
953961
/* check requested priority */
954-
if ((prio > rtapi_prio_highest()) || (prio < rtapi_prio_lowest()))
962+
if (!prio_check(prio))
955963
{
964+
rtapi_print_msg(RTAPI_MSG_ERR,"rtapi:task_new prio is not in bound lowest %i prio %i highest %i\n",
965+
rtapi_prio_lowest(), prio, rtapi_prio_highest());
956966
return -EINVAL;
957967
}
958968

0 commit comments

Comments
 (0)