POSIX scheduling and priority question

Sebastian Huber sebastian.huber at embedded-brains.de
Tue Apr 22 13:32:56 UTC 2014


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