Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing priority change of running thread, alt missing max prio option #8

Open
JonoJensen opened this issue Jul 4, 2016 · 1 comment

Comments

@JonoJensen
Copy link

Hi

Suggestion:
Add le_thread_SetPriorityRunning(,,) or maxpriority: to .adef.

We:re trying to achieve:

  • Legato thread running with normal prio.
  • Worker thread running with RR scheduling at _RT_1

How can we to this?

We either lack posibility to set max prio in .adef (can only set prio of main process, other threads can be set to same or lower)

OR

We lack posibility to lower prio on running process (set prio in .adef to rt1, create worker, set worker prio to rt1, lower prio of legato to normal (this operation is missing)).
If we call
result = le_thread_SetPriority(main_thread, LE_THREAD_PRIORITY_NORMAL);
We get
Jan 6 03:25:00 | Legato | spihandler[5928]/framework T=main | thread.c SetSchedPolicyAttr() 447 | Attempt to set scheduling policy on running thread 'main'.

It would be nice to have le_thread_SetPriorityRunning(,,) that would do same as below + update legato internal struct (if this now works, it's unveriified).

We can do this manually but it's unclear if this breaks legato (has internal struct that will not be correct afterwards:

        {
            int s;
            struct sched_param param = { .sched_priority = 0 };

            //Set policy and attributes 
            s = pthread_setschedparam(pthread_self(), SCHED_OTHER, &param);
            if(s != 0)
            {
                LE_FATAL("Failed setting phtread sched params");
            }
        }

(Note: Prio in .adef needs to be set to rt2 to work around bug in legato.)

@jtchitty
Copy link
Contributor

Yeah, there's definitely some problems with the threading. 79f0216 fixes a bunch of the problems. maxPriority in .adefs is coming too.

You should be fine setting the priority using POSIX APIs, but I agree it would be good to have a Legato function for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants