EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Changing EPICS general Purpose Thread's Priorities
From: "Kim, Kukhee via Tech-talk" <tech-talk at aps.anl.gov>
To: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>, "jun-ichi.odagiri at kek.jp" <jun-ichi.odagiri at kek.jp>
Date: Fri, 26 Mar 2021 15:59:52 +0000
Dear Odagiri san,

Long time no see, I am glad to see your message 🙂


> Can I change the priority of "CAS-TCP" thread and "scan-10"
> thread so that the former is given a higher priority than
> that of the latter without modifying any source files in
> base?


It is possible to modify thread priority after the launching process, even possible to modify the scheduling policy (ex, SCHED_OTERH to SCHED_FIFO, to the real-time priority).
Please, check up the followings:

I am using linuxRT - preempted rt patch for this example.

uname -a
Linux cpu-b084-pm01 4.14.139-rt66 #1 SMP PREEMPT RT Mon Sep 30 14:33:17 PDT 2019 x86_64 GNU/Linux

We can check up process id, parent id, thread id, rt-priority, start time, running time, and thread name with the following command.

ps -Leo pid,ppid,tid,rtprio,stime,time,comm

21994 21993 22010      - Mar23 00:00:00 tpg
21994 21993 22011      - Mar23 00:00:00 tpg
21994 21993 22209     59 Mar23 00:00:00 timerQueue
21994 21993 22210     59 Mar23 00:00:00 timerQueue
21994 21993 22212      - Mar23 00:00:00 tpg
21994 21993 22215      - Mar23 00:00:00 tpg
21994 21993 22216     10 Mar23 00:00:00 taskwd
21994 21993 22217     69 Mar23 00:00:00 timerQueue
21994 21993 22218     58 Mar23 00:01:39 cbLow
21994 21993 22219     63 Mar23 00:00:00 cbMedium
21994 21993 22220     70 Mar23 00:00:00 cbHigh
21994 21993 22221     50 Mar23 00:00:00 dbCaLink
21994 21993 22222     98 Mar23 00:12:35 tpgIrqPollingTa
21994 21993 22223     89 Mar23 00:04:02 tpgSoftPollingT
21994 21993 22224     50 Mar23 00:02:59 tpgBsaPollingTa
21994 21993 22225     10 Mar23 00:01:13 tpgRateMeasureP
21994 21993 22226     10 Mar23 00:02:07 tpgDiagnosticsT
21994 21993 22227     50 Mar23 00:02:40 bsaDrvPoll
21994 21993 22228     57 Mar23 00:00:13 timerQueue
21994 21993 22229     66 Mar23 00:00:00 scanOnce
21994 21993 22230     59 Mar23 00:00:00 scan-10
21994 21993 22231     60 Mar23 00:00:00 scan-5
21994 21993 22232     61 Mar23 00:00:01 scan-2
21994 21993 22233     62 Mar23 00:00:07 scan-1
21994 21993 22234     63 Mar23 00:00:14 scan-0.5
21994 21993 22235     64 Mar23 00:00:09 scan-0.2
21994 21993 22236     65 Mar23 00:00:18 scan-0.1
21994 21993 22237     56 Mar23 00:00:00 asCaTask
21994 21993 22238     16 Mar23 00:00:00 CAS-TCP
21994 21993 22239     12 Mar23 00:00:54 CAS-UDP
21994 21993 22240     14 Mar23 00:00:00 CAS-beacon
21994 21993 22241     51 Mar23 00:00:00 CAC-event
21994 21993 22242     10 Mar23 00:00:00 logRestart
21994 21993 22243     10 Mar23 00:00:00 caPutLog
21994 21993 22244     20 Mar23 00:00:24 save_restore
21994 21993 22245     10 Mar23 00:00:00 ipToAsciiProxy
21994 21993 22246     22 Mar23 00:01:42 timerQueue
21994 21993 22247     24 Mar23 00:00:27 CAC-UDP
21994 21993 22250     22 Mar23 00:00:04 CAC-event
21994 21993 22778     18 08:36 00:00:00 CAS-event
21994 21993 22779     20 08:36 00:00:00 CAS-client
22756  6877 22756      - 08:28 00:00:00 dropbear

The 3rd column is thread id, and the 4th column is a priority.  The symbol "-" means no rt-priority for the thread, SCHED_OTHER.
The thread "scan-10" has thread id 22230 and rt-priority 59.
The thread "CAS-TCP" has thread id 22238 and rt-priority 16.

If we want to escalate the rt-priority for those threads, we can do the followings:

# Escalate rt-priority of scan-10 to 60
chrt -f -p 60 22230
pid 22230's current scheduling policy: SCHED_FIFO
pid 22230's current scheduling priority: 59
pid 22230's new scheduling policy: SCHED_FIFO
pid 22230's new scheduling priority: 6

# Escalate rt-priority of CAS-TCP to 20
chrt -f -p 20 22238
pid 22238's current scheduling policy: SCHED_FIFO
pid 22238's current scheduling priority: 16
pid 22238's new scheduling policy: SCHED_FIFO
pid 22238's new scheduling priority: 20

Then, you can see the priorities of those two threads were escalated.

21994 21993 22229     66 Mar23 00:00:00 scanOnce
21994 21993 22230     60 Mar23 00:00:00 scan-10        <==========   59 to 60
21994 21993 22231     60 Mar23 00:00:00 scan-5
21994 21993 22232     61 Mar23 00:00:01 scan-2
21994 21993 22233     62 Mar23 00:00:07 scan-1
21994 21993 22234     63 Mar23 00:00:14 scan-0.5
21994 21993 22235     64 Mar23 00:00:09 scan-0.2
21994 21993 22236     65 Mar23 00:00:18 scan-0.1
21994 21993 22237     56 Mar23 00:00:00 asCaTask
21994 21993 22238     20 Mar23 00:00:00 CAS-TCP       <========= 16 to 20
21994 21993 22239     12 Mar23 00:00:54 CAS-UDP
21994 21993 22240     14 Mar23 00:00:00 CAS-beacon


I think the help message of the "chrt" will be helpful.

chrt --help
BusyBox v1.31.0 (2019-09-30 13:30:59 PDT) multi-call binary.

Usage: chrt -m | -p [PRIO] PID | [-rfobi] PRIO PROG [ARGS]

Change scheduling priority and class for a process

-m Show min/max priorities
-p Operate on PID
-r Set SCHED_RR class
-f Set SCHED_FIFO class
-o Set SCHED_OTHER class
-b Set SCHED_BATCH class
-i Set SCHED_IDLE class


Thank you.
Best regards,
Kukhee




From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of jun-ichi.odagiri--- via Tech-talk <tech-talk at aps.anl.gov>
Sent: Friday, March 26, 2021 12:09 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Changing EPICS general Purpose Thread's Priorities
 
Dear Han san,

Thank you for sending me the information.
I took a look at the site you have let me know.
But, I may be dense, I could not get the point.
It seems like that the information on the site is related
to Multi-Core Linux.

To be more concrete, I tell you what I have in my mind as
follows.

1. A Single-Core CPU is running Linux.
2. Only one IOC program is running on the Linux.
3. The IOC program is multi-threaded, as every one knows.

Here is my question.

Can I change the priority of "CAS-TCP" thread and "scan-10"
thread so that the former is given a higher priority than
that of the latter without modifying any source files in
base?

Does the site you guided me to answer the question?

Thanks a lot again in advance.

Best regards,

J.Odagiri at KEK. 


----- Original Message -----
> Jun-ichi Odagiri san,
>
> This may be what you are looking for.
>
> https://github.com/epics-modules/MCoreUtils
>
> Best,
> Han
>
>
> On Thu, Mar 25, 2021 at 4:55 PM jun-ichi.odagiri--- via Tech-talk
> <tech-talk at aps.anl.gov> wrote:
> >
> > Hi, all
> >
> > Do we have a way to change the priorities of the EPICS
> > general purpose threads dynamically on the iocsh?
> >
> > Thanks a lot in advance.
> >
> > Jun-ichi Odagiri(KEK)
> >
> >
> >
>



Replies:
Re: Changing EPICS general Purpose Thread's Priorities jun-ichi.odagiri--- via Tech-talk
References:
MRF kernel module, failed to map BARS GAGET Alexis via Tech-talk
Re: MRF kernel module, failed to map BARS Michael Davidsaver via Tech-talk
RE: MRF kernel module, failed to map BARS GAGET Alexis via Tech-talk
Changing EPICS general Purpose Thread's Priorities jun-ichi.odagiri--- via Tech-talk
Re: Changing EPICS general Purpose Thread's Priorities Jeong Han Lee via Tech-talk
Re: Changing EPICS general Purpose Thread's Priorities jun-ichi.odagiri--- via Tech-talk

Navigate by Date:
Prev: Re: Changing EPICS general Purpose Thread's Priorities Ralph Lange via Tech-talk
Next: Phoebus lock down BOB Stainer Tom via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: Changing EPICS general Purpose Thread's Priorities Jeong Han Lee via Tech-talk
Next: Re: Changing EPICS general Purpose Thread's Priorities jun-ichi.odagiri--- via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 30 Mar 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·