Commit 295adc21 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Plc threads can now use SCHED_DEADLINE by setting a deadline > 0

parent 8232b1e3
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
Run a PLC thread. */ Run a PLC thread. */
#include <errno.h> #include <errno.h>
#include <float.h>
#include <pwd.h> #include <pwd.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
...@@ -313,8 +314,8 @@ void plc_thread(plc_sThread* tp) ...@@ -313,8 +314,8 @@ void plc_thread(plc_sThread* tp)
tp->init(1, tp); tp->init(1, tp);
if (tp->PlcThread->Prio < 0) { if (tp->PlcThread->Deadline > FLT_EPSILON) {
thread_SetDeadline(tp->PlcThread); sts = thread_SetDeadline(tp->PlcThread);
} else { } else {
sts = thread_SetPrio(&tp->tid, tp->prio); sts = thread_SetPrio(&tp->tid, tp->prio);
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
*/ */
#include <errno.h> #include <errno.h>
#include <float.h>
#include <inttypes.h> #include <inttypes.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -248,11 +249,11 @@ pwr_tStatus thread_SetDeadline(pwr_sClass_PlcThread* o) ...@@ -248,11 +249,11 @@ pwr_tStatus thread_SetDeadline(pwr_sClass_PlcThread* o)
o->Description, attr.sched_period / (1000 * 1000), o->Description, attr.sched_period / (1000 * 1000),
attr.sched_runtime / (1000 * 1000)); attr.sched_runtime / (1000 * 1000));
} }
/*if (o->Deadline) { if (o->Deadline > FLT_EPSILON) {
attr.sched_deadline = toNs(o->Deadline); attr.sched_deadline = toNs(o->Deadline);
} else {*/ } else {
attr.sched_deadline = toNs(o->ScanTime); attr.sched_deadline = toNs(o->ScanTime);
//} }
int ret = sched_setattr(tid, &attr, 0); int ret = sched_setattr(tid, &attr, 0);
if (ret != 0) { if (ret != 0) {
......
...@@ -74,6 +74,14 @@ SObject pwrb:Class ...@@ -74,6 +74,14 @@ SObject pwrb:Class
EndBody EndBody
EndObject EndObject
!/** !/**
! Deadline for the plc thread.
!*/
Object Deadline $Attribute 37
Body SysBody
Attr TypeRef = "pwrs:Type-$Float32"
EndBody
EndObject
!/**
! Plc thread options. ! Plc thread options.
! Specification of the action when the execution time exceeds ! Specification of the action when the execution time exceeds
! the scantime. ! the scantime.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment