* [Xenomai-core] setting priority
@ 2009-11-05 9:20 tarek ben ali
2009-11-05 9:44 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: tarek ben ali @ 2009-11-05 9:20 UTC (permalink / raw)
To: Xenomai help, xenomai
[-- Attachment #1: Type: text/plain, Size: 3538 bytes --]
I'm trying to set priority to a specified process on including its PID,the
code below is running BUT after allocating priority and policy the output
of "top" commande seems not changing(the priority of the process specified
is still the same).Is there any explanation please?
#include <sched.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include "posixtest.h"
struct unique {
int value;
char *name;
} sym[] = {
{
SCHED_FIFO, "SCHED_FIFO"
},
{
SCHED_RR, "SCHED_RR"
},
//#if defined(_POSIX_SPORADIC_SERVER) ||
defined(_POSIX_THREAD_SPORADIC_SERVER)
// {
// SCHED_SPORADIC,"SCHED_SPORADIC"
// },
//#endif
{
SCHED_OTHER, "SCHED_OTHER"
},
{
0, 0
}
};
int main(int argc, char **argv)
{
int tmp, policy, priority,pid, result = PTS_PASS,old_priority,
old_policy;
struct sched_param param;
struct unique *tst;
printf("Set the PID of the process you want to modifie its priority:
");
scanf("%d",&pid);
if(sched_getparam(pid, ¶m) == -1) {
perror("An error occurs when calling sched_getparam()");
return PTS_UNRESOLVED;
}
old_priority = param.sched_priority;
old_policy = sched_getscheduler(pid);
printf("The current priority set is %d and the the current policy is
%d \n",old_priority,old_policy);
printf("******************************************************************\n
");
if(old_policy == -1) {
perror("An error occurs when calling sched_getscheduler()");
return PTS_UNRESOLVED;
}
tst = sym;
while (tst->name) {
fflush(stderr);
printf("Policy: %s\n", tst->name);
fflush(stdout);
policy = tst->value;
//priority = ( sched_get_priority_min(policy) +
// sched_get_priority_max(policy) ) / 2;
priority=1;
param.sched_priority = priority;
tmp = sched_setscheduler(pid, policy, ¶m);
if(tmp == -1 || errno != 0) {
if(errno == EPERM){
printf(" The process do not have permission
to change its own scheduler\n Try to run this test as root.\n");
} else {
printf(" Error calling sched_setscheduler()
for %s policy\n", tst->name);
}
if(result != PTS_FAIL) result = PTS_UNRESOLVED;
tst++;
continue;
}
if(sched_getparam(pid, ¶m) != 0) {
perror("Error calling sched_getparam()");
return PTS_UNRESOLVED;
}
if(policy != sched_getscheduler(pid)){
printf(" sched_setscheduler() does not set the
policy to %s.\n", tst->name);
result = PTS_FAIL;
}
if(priority != param.sched_priority) {
printf(" sched_setscheduler() does not set the
right param for %s policy.\n", tst->name);
result = PTS_FAIL;
}
tst++;
}
if(result == PTS_PASS)
printf("Test PASSED\n");
return result;
}
[-- Attachment #2: Type: text/html, Size: 4155 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] setting priority
2009-11-05 9:20 [Xenomai-core] setting priority tarek ben ali
@ 2009-11-05 9:44 ` Gilles Chanteperdrix
2009-11-05 13:38 ` tarek ben ali
0 siblings, 1 reply; 4+ messages in thread
From: Gilles Chanteperdrix @ 2009-11-05 9:44 UTC (permalink / raw)
To: tarek ben ali; +Cc: Xenomai help, xenomai
tarek ben ali wrote:
>
> I'm trying to set priority to a specified process on including its
> PID,the code below is running BUT after allocating priority and policy
> the output of "top" commande seems not changing(the priority of the
> process specified is still the same).Is there any explanation please?
Here we know a few things or two about Xenomai, not about top. So, I
have no idea. Now, if you are trying to set the priority of a Xenomai
thread using Xenomai posix skin, as I already told you in the previous
mail, you have to use services described here, not sched_setscheduler:
http://www.xenomai.org/documentation/xenomai-2.4/html/api/group__posix__sched.html
--
Gilles
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] setting priority
2009-11-05 9:44 ` Gilles Chanteperdrix
@ 2009-11-05 13:38 ` tarek ben ali
2009-11-05 13:42 ` Gilles Chanteperdrix
0 siblings, 1 reply; 4+ messages in thread
From: tarek ben ali @ 2009-11-05 13:38 UTC (permalink / raw)
To: Gilles Chanteperdrix; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 776 bytes --]
2009/11/5 Gilles Chanteperdrix <>
Gilles would you like to take a look on this please:
#include <sched.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
struct sched_param param;
param.sched_priority = 99;
sched_setscheduler(0, SCHED_FIFO, ¶m);
while(1) sleep(1);
exit(0);
}
-->
/root> ./t&
/root> ps l
F UID PID PPID PRI NI VSZ RSS WCHAN STAT TTY TIME COMMAND
4 0 2984 2881 -100 - 1548 284 - SN pts/0 0:00 ./t
0 0 2988 2881 20 0 2348 740 - R+ pts/0 0:00 ps l
the process has no longer a priority due to the set of SCHED_FIFO ,moreover
it's marked as an RT task.
The question is when defining a PID of process running(ex:3760 firefox )
this result is lost!!
[-- Attachment #2: Type: text/html, Size: 1080 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Xenomai-core] setting priority
2009-11-05 13:38 ` tarek ben ali
@ 2009-11-05 13:42 ` Gilles Chanteperdrix
0 siblings, 0 replies; 4+ messages in thread
From: Gilles Chanteperdrix @ 2009-11-05 13:42 UTC (permalink / raw)
To: tarek ben ali; +Cc: xenomai
tarek ben ali wrote:
>
>
> 2009/11/5 Gilles Chanteperdrix <>
> Gilles would you like to take a look on this please:
No. This is not related to Xenomai. At all.
--
Gilles
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-05 13:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05 9:20 [Xenomai-core] setting priority tarek ben ali
2009-11-05 9:44 ` Gilles Chanteperdrix
2009-11-05 13:38 ` tarek ben ali
2009-11-05 13:42 ` Gilles Chanteperdrix
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.