POSIX scheduling and priority question

Gempeler Stefan Stefan.Gempeler at nanotronic.ch
Wed Apr 23 07:24:31 UTC 2014


Hi Joel, thanks for your reply.
I used to pass NULL as attributes in the past (running the application
on a Ubuntu/Qt environment did run well), but on the target system
running on RTEMS I need to set the priorities (see original message).
Those attributes seem to be system dependent: on RTEMS the
PTHREAD_EXPLICIT_SCHED has to be set to run the example successfully.
This did not work on the Ubuntu system (error while creating the
threads). On Ubuntu, the PTHREAD_INHERIT_SCHED has to be chosen...

I attached the final test code. Feel free to use/change/include it
wherever you like.
Stefan

On 4/22/2014 9:39 AM, Gempeler Stefan wrote:
> Hi Sebastian, thanks for your fast reply. Using PTHREAD_EXPLICIT_SCHED
seems to solve the problem.
I was writing a reply when Sebastian's showed up. Glad it was right. :)

As a final throw in, passing NULL as the attributes to pthread_create()
uses the implementation's default attribute set. POSIX does not specify
what that is. So when you use NULL there, all bets are off for portable
behavior.

If you don't mind, could you clean up the entire example and provide a
README? If you are willing and make the code BSD or "as is" type
license, it would be good to put in examples-v2/posix.
> 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
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: test4.c
Type: application/octet-stream
Size: 4260 bytes
Desc: test4.c
URL: <http://lists.rtems.org/pipermail/users/attachments/20140423/a8b3adc1/attachment-0001.obj>


More information about the users mailing list