AW: POSIX scheduling and priority question

Gempeler Stefan Stefan.Gempeler at nanotronic.ch
Tue Apr 22 14:39:32 UTC 2014


Hi Sebastian, thanks for your fast reply. Using PTHREAD_EXPLICIT_SCHED seems to solve the problem.

For the sake of completeness
************************************************************************************

	printk( "\n\n========= STARTING ============  %s, %s\n", __DATE__, __TIME__);

	// start the waiting task, highest priority
	test_param.sched_priority = sched_get_priority_max( SCHEDULER_POLICY );
	pthread_attr_setschedparam( &test_attr, &test_param );
	pthread_attr_setinheritsched( &test_attr, PTHREAD_EXPLICIT_SCHED );
	pthread_create( &thread_wait,	&test_attr,	test_wait_thread,	0 );

	// start the full running task, lowest priority
	test_param.sched_priority = sched_get_priority_min( SCHEDULER_POLICY );
	pthread_attr_setschedparam( &test_attr, &test_param );
	pthread_attr_setinheritsched( &test_attr, PTHREAD_EXPLICIT_SCHED );
	pthread_create( &thread_full,	&test_attr,	test_full_thread,	0 );

************************************************************************************

Kind regards 
Stefan


-----Ursprüngliche Nachricht-----
Von: Sebastian Huber [mailto:sebastian.huber at embedded-brains.de] 
Gesendet: Dienstag, 22. April 2014 15:33
An: Gempeler Stefan
Cc: rtems-users at rtems.org
Betreff: Re: POSIX scheduling and priority question

On 2014-04-22 14:53, Gempeler Stefan wrote:
[...]
> void *POSIX_Init( void *argument )
>
> {
>
> #define SCHEDULER_POLICY                     (SCHED_RR)
>
>                  pthread_t           thread_full;
>
>                  pthread_t           thread_wait;
>
>                  pthread_attr_t                test_attr;
>
>                  struct sched_param       test_param;
>
>                  assert( sem_init( &test_semaphore, 0, 0 )==0 );

This is very dangerous since #define NDEBUG will wipe out this function call.

>
>                  // get default attributes
>
>                  pthread_attr_init( &test_attr );
>
>                  // store parameters
>
>                  pthread_attr_getschedparam( &test_attr, &test_param 
> );
>
>                  // set policy
>
>                  pthread_attr_setschedpolicy( &test_attr, 
> SCHEDULER_POLICY );
>
>                  printk( "\n\n========= STARTING ============  \n" );
>
>                  // start the waiting task, highest priority
>
>                  test_param.sched_priority = sched_get_priority_max( 
> SCHEDULER_POLICY );
>
>                  assert( pthread_attr_setschedparam( &test_attr, 
> &test_param
> )==0 );

See also PTHREAD_INHERIT_SCHED vs. PTHREAD_EXPLICIT_SCHED.

>
>                  pthread_create( &thread_wait,              &test_attr,
> test_wait_thread,          0 );

[...]

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.






More information about the users mailing list