Skip to content

Commit 67d7034

Browse files
committed
Fix priority check for LXRT
1 parent ccb56bf commit 67d7034

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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
@@ -869,6 +869,14 @@ int RtapiApp::prio_bound(int prio) const {
869869
return prio;
870870
}
871871

872+
bool RtapiApp::prio_check(int prio) const {
873+
if(rtapi_prio_highest() > rtapi_prio_lowest()) {
874+
return (prio <= rtapi_prio_highest()) && (prio >= rtapi_prio_lowest());
875+
} else {
876+
return (prio <= rtapi_prio_lowest()) && (prio >= rtapi_prio_highest());
877+
}
878+
}
879+
872880
int RtapiApp::prio_next_higher(int prio) const
873881
{
874882
prio = prio_bound(prio);
@@ -899,8 +907,10 @@ int RtapiApp::allocate_task_id()
899907
int RtapiApp::task_new(void (*taskcode) (void*), void *arg,
900908
int prio, int owner, unsigned long int stacksize, int uses_fp) {
901909
/* check requested priority */
902-
if ((prio > rtapi_prio_highest()) || (prio < rtapi_prio_lowest()))
910+
if (!prio_check(prio))
903911
{
912+
rtapi_print_msg(RTAPI_MSG_ERR,"rtapi:task_new prio is not in bound lowest %i prio %i highest %i\n",
913+
rtapi_prio_lowest(), prio, rtapi_prio_highest());
904914
return -EINVAL;
905915
}
906916

0 commit comments

Comments
 (0)