RTEMS Sporadic Server BUG or FEATURE?
Alex
kbyte at iol.pt
Wed May 25 14:19:55 UTC 2005
Hello,
Suppose a program with the single POSIX thread (main) using the SCHED_SPORADIC policy.
When specifying the following properties:
...
scparam.ss_replenish_period.tv_sec=1
scparam.ss_replenish_period.tv_nsec=500000000
scparam.ss_initial_budget.tv_sec=1
scparam.ss_initial_budget.tv_nsec=250000000
scparam.sched_priority=254
scparam.ss_low_priority=252
...
one hopes that the thread will execute for 1,25 seconds in 254 priority, right?
As there is only one thread, next the thread will execute during a 1,5 seconds with priority 252.
Is this right?
while(1)
{
"print pthread_getschedparam(...).priority"
}
When I execute the test program what I see is that the thread executes 1,25 seconds in the 254 priority and
a few instants (< 0,5 seconds) in the 252 priority.
Why the thread doens't executes all the replenish period in the 252 priority?
Next, I tried to change the properties like this:
...
scparam.ss_replenish_period.tv_sec=3
scparam.ss_replenish_period.tv_nsec=500000000
scparam.ss_initial_budget.tv_sec=1
scparam.ss_initial_budget.tv_nsec=250000000
scparam.sched_priority=254
scparam.ss_low_priority=252
...
Executing the program I see that the thread executes about one second in
254 priority and about 3 seconds in the 252 priority. Good.
Next, I tried to change the properties like this:
...
scparam.ss_replenish_period.tv_sec=5
scparam.ss_replenish_period.tv_nsec=500000000
scparam.ss_initial_budget.tv_sec=1
scparam.ss_initial_budget.tv_nsec=250000000
scparam.sched_priority=254
scparam.ss_low_priority=252
...
Executing the program I see that the thread executes about one second in
254 priority and about 5 seconds in the 252 priority.Good.
Conclusion, it seems like the specified replenish period must always be > 2*budget ?!
Is this the normal behaviour of the SPORADIC Server?
In all tests I used the following configuration:
...
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
...
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_TICKS_PER_TIMESLICE 1
...
Thank you for your attention,
Alex
Here is the complete test source code (based on rtems samples):
#define CONFIGURE_INIT
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sched.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <rtems.h>
#include <bsp.h>
#include <pthread.h>
#define CONFIGURE_INIT_TASK_ENTRY_POINT POSIX_Init
pthread_t Init_id;
pthread_t Task_id;
void *POSIX_Init(void *argument)
{
int status;
int passes;
int schedpolicy;
int priority;
struct sched_param schedparam;
Init_id = pthread_self();
printk( "Init's ID is 0x%08x\n", Init_id );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status );
priority = schedparam.sched_priority;
printk(" - current priority = %d", priority );
schedparam.ss_replenish_period.tv_sec = 5;
schedparam.ss_replenish_period.tv_nsec = 500000000;
schedparam.ss_initial_budget.tv_sec = 1;
schedparam.ss_initial_budget.tv_nsec = 250000000;
schedparam.sched_priority = 254;
schedparam.ss_low_priority = 252;
status = pthread_setschedparam( pthread_self(), SCHED_SPORADIC, &schedparam );
assert( !status );
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status );
priority = schedparam.sched_priority;
printk("\n - new priority = %d", priority );
/* go into a loop consuming CPU time to watch our priority change */
for ( passes=0 ; passes <= 9 ; )
{
status = pthread_getschedparam( pthread_self(), &schedpolicy, &schedparam );
assert( !status );
if ( priority != schedparam.sched_priority )
{
priority = schedparam.sched_priority;
printk("\n new priority = %d", priority );
passes++;
}
}
exit(0);
}
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_THREADS 2
#define CONFIGURE_MAXIMUM_POSIX_KEYS 10
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES 10
#define CONFIGURE_POSIX_INIT_THREAD_TABLE
#define CONFIGURE_MICROSECONDS_PER_TICK 1000
#define CONFIGURE_TICKS_PER_TIMESLICE 1
#include <confdefs.h>
_________________________________________________________________________________
NOVO! Filtro de Anti-SPAM IOL reduz o lixo na sua caixa de correio em mais de 80%
Servicos IOL COMPLETO e IOL SEGURO.
Saiba Mais em http://www.iol.pt/correio/rodape.php?dst=0505121
More information about the users
mailing list