Commit bac4c44e authored by Pfeiffer, Götz's avatar Pfeiffer, Götz
Browse files

High task priorities have to be set directly, EPICS-OSI doesn't support this.


The thread creation functions in EPICS OSI do not allow to set the thread
priority above a certain limit. This conflicts with the currently used
priorities of some threads in the MultiCAN device support.

In a previous patch we used patched version of the EPICS base (version 3.14.12)
where a new function, epicsThreadCreateOSPrio, was implemented. Since it was
rejected to include these changes in the EPICS base, we now take a different
approach.

This version of MultiCAN uses our standard EPICS base version 3.14.12.1.

After thread creation, the thread priority is changed to the specified value by
directly calling the appropriate functions of the oprtating system.  Note that
for the RTEMS version the inclusion of the header files is still missing.
parent 1867f2b0
......@@ -53,6 +53,13 @@
#include "gps_defs.h"
#if defined(B_VXWORKS)
#include <taskLib.h>
#endif
#if defined(B_RTEMS)
#include <rtems.h>
#endif
#define GPS_WRITER_PRI 67
#define GPS_READER_PRI 40
......@@ -350,11 +357,25 @@ gps_Return gps_inits (
*
**************************************************************************-*/
static void set_prio(epicsThreadId id, int prio)
{
#ifdef B_VXWORKS
taskPrioritySet((int)id, prio);
#endif
#ifdef B_RTEMS
{
rtems_task_priority old;
rtems_task_set_priority((rtems_id)id, prio, &old);
}
#endif
}
long gpsStart (void)
{
int cnt; /* protocol index */
char task_name[12]; /* Numbers to build the task's name */
static int started = FALSE;
epicsThreadId tid;
if (started) return 0;
......@@ -374,42 +395,47 @@ long gpsStart (void)
continue;
}
sprintf (task_name, "mC %s", gps_table[cnt].name);
if ((epicsThreadId)0 ==
epicsThreadCreateOSPrio(task_name, GPS_READER_PRI,
tid=
epicsThreadCreate(task_name, GPS_READER_PRI,
epicsThreadGetStackSize(epicsThreadStackSmall),
(EPICSTHREADFUNC) gps_reader, (void *) cnt))
(EPICSTHREADFUNC) gps_reader, (void *) cnt);
if ((epicsThreadId)0 == tid)
{
gps_err(GPS_NO_SPAWN, task_name);
DBG(5, "Leaving gpsStart.");
return -1;
}
set_prio(tid, GPS_READER_PRI);
PRF(3, ("Task %s started successfully.\n", task_name));
}
/* bfr 20/07/04: Moved start of writer task from gpsInit to here. */
/* Start Writer Task */
if ((epicsThreadId)0 ==
epicsThreadCreateOSPrio("mC Writer", GPS_WRITER_PRI,
tid=
epicsThreadCreate("mC Writer", GPS_WRITER_PRI,
epicsThreadGetStackSize(epicsThreadStackSmall),
(EPICSTHREADFUNC) gps_writer, NULL))
(EPICSTHREADFUNC) gps_writer, NULL);
if ((epicsThreadId)0 == tid)
{
gps_err(GPS_NO_SPAWN, "mC Writer");
return -1;
}
set_prio(tid, GPS_WRITER_PRI);
DBG(3, "Task mC Writer startet successfully.");
/* Start watchdog */
if ((epicsThreadId)0 ==
epicsThreadCreateOSPrio("mC Timer", GPS_TIMER_PRI,
tid= /* Start watchdog */
epicsThreadCreate("mC Timer", GPS_TIMER_PRI,
epicsThreadGetStackSize(epicsThreadStackSmall),
(EPICSTHREADFUNC) gps_timer, NULL))
(EPICSTHREADFUNC) gps_timer, NULL);
if ((epicsThreadId)0 == tid)
{
gps_err(GPS_NO_SPAWN, "mC Timer");
DBG(5, "Leaving gpsStart.");
return -1;
}
set_prio(tid, GPS_TIMER_PRI);
DBG(3, "Task mC Timer started successfully.");
DBG(5, "Leaving gpsStart.");
return 0;
......
......@@ -156,6 +156,13 @@ Version 1.1:
#include <unistd.h>
#endif /*@IL*/
#if defined(B_VXWORKS)
#include <taskLib.h>
#endif
#if defined(B_RTEMS)
#include <rtems.h>
#endif
#ifdef EPICS_OSI /*@IL*/
#include <epicsThread.h> /*@IL*/
#endif /*@IL*/
......@@ -256,7 +263,6 @@ static int init_sched(int prio, boolean rel_prio,
}
#endif
/*@EX(5)*/
boolean pth_start_thread_named(pth_thread th, pth_struc *pst,
int stack,
......@@ -333,6 +339,15 @@ boolean pth_start_thread_named(pth_thread th, pth_struc *pst,
if (NULL == (pst->tid = epicsThreadCreate(name, prio, stack,
(EPICSTHREADFUNC) th, arg)))
return FALSE;
#ifdef B_VXWORKS
taskPrioritySet((int)(pst->tid), prio);
#endif
#ifdef B_RTEMS
{
rtems_task_priority old;
rtems_task_set_priority((rtems_id)pst->tid, prio, &old);
}
#endif
return TRUE;
}
#endif
......
......@@ -26,7 +26,7 @@ DEVHWCLIENT=$(SUPPORT)/soft/devHwClient/3-0
VMETAS=$(SUPPORT)/bspDep/VMEtas/2-0
# EPICS_BASE usually appears last so other apps can override stuff:
EPICS_BASE=/opt/Epics/R3.14.12/base/3-14-12-2-2
EPICS_BASE=/opt/Epics/R3.14.12/base/3-14-12-2-1
#Capfast users may need the following definitions
#CAPFAST_TEMPLATES=
......
Supports Markdown
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