Linux not respecting SCHED_FIFO priority ? ( normal or GDB execution )

前端 未结 3 1646
清歌不尽
清歌不尽 2021-01-24 01:08

TL;DR

On multiprocessors/multicores engines, more than one RT SCHED_FIFO threads may be scheduled on more than one execution unit. So thread wit

3条回答
  •  难免孤独
    2021-01-24 01:13

    A new answer to gather the remaining problems I had for Debugging.

    Answers like Setting application affinity in gdb / Markus Ahlberg or questions like gdb don't break when I use exec-wrapper script to exec my target binary gave a solution with the use of the GDB option exec-wrapper but then I was not (always) able to set breakpoints in my code (even trying my own wrapper)

    I finally came back to this solution again Setting application affinity in gdb / Craig Scratchley

    The initial problem

    $ ./main
    Result: inf
    

    The solution for run-time

    taskset -c 0 ./main
    Result: 0.333333
    

    But for debug

    gdb -ex 'set exec-wrapper taskset -c 0' ./main
    --> mixed result depending on conditions (native/virtualized ? Number of cores ? ) 
    sometimes 0.333333 sometimes inf
    --> problem to set breakpoints
    --> still work to do for me to summarize this issue
    

    or

    taskset -c 0 gdb main
    ...
    (gdb) r
    ...
    Result: inf
    

    and finally

    taskset -c N chrt 99 gdb main <<-- where N is a core number (*)
    ...                           <<-- 99 denotes here "your higher prio in your system"
    (gdb) r
    ...
    Result: 0.333333
    
    • I wrote N above because if your program main sets it's affinity to processor M and you set gdb affinity to N, you may get trouble the same original problem
    • I wrote only chrt 99 for GDB even if I am interested in SCHED_FIFO and not SCHED_RR because I experienced gdb ( or IDE see below ) freezes if option -f ( for fifo ) was used. I suspect the roud robin mechanism is safer as a thread will always release at some point

    And if you have an IDE (but do not know how to set gdb properly inside this IDE) I was able to do

    taskset -c N chrt 99 code
    

提交回复
热议问题