From: Paolo Gai <pj@domain.hid>
To: Paolo Gai <pj@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Xenomai 2.0.1 - Posix Skin - realtime priorities - what I'm doing wrong?
Date: Sat, 10 Dec 2005 12:14:31 +0100 [thread overview]
Message-ID: <439AB897.1020304@domain.hid> (raw)
In-Reply-To: <439AB3B6.2080503@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 3208 bytes --]
Ok, after having clicked ion the send button, I also discovered that
NPTL uses INHERIT_SCHED by default in the pthread attributes
http://sources.redhat.com/bugzilla/show_bug.cgi?id=145
I added it to the original examples, and I obtained the following
(basically it is similar to the Case 1 depicted before...)
Linux Real-Time Threads
[root@domain.hid xenomai-demos]# ./ex_rr
LOW priority thread!!!
...........###########............############...........###########...........###########............############...........###########............############...........###########...........###########............############...........###########...........###########............############...........###########...........###########............############...........###########............############...........###########...........###########............############...........###########...........###########............############...........###########...........###########.....#####LOW
priority thread!!!
............................................................................................................................................................................................................................................................................................................############################################################################################################################################################################################################################################################################################################[root@domain.hid
xenomai-demos]#
--> that's fine;
Xenomai Threads:
[root@domain.hid xenomai-demos]# ./rt_ex_rr
LOW priority thread!!!
.....###................................................................................###############################################################################...............................................................................################################################################################................................................................................###############################################################################........................................................###########################################################............................................................................................................................................................................................................................................................................................................LOW
priority thread!!!
############################################################################################################################################################################################################################################################################################################[root@domain.hid
xenomai-demos]#
That is not what should be :-(
Again, in this case there may be an additional influence of using the
stdio with mutexes and so on...
bye
Paolo
[-- Attachment #2: ex_rr.c --]
[-- Type: text/x-csrc, Size: 3221 bytes --]
/*
* Linux FIFO/RR scheduler demo
*
* This demo creates a few tasks scheduled with the SCHED_FIFO or the
* SCHED_RR scheduler
*
* Copyright (C) 2002 by Paolo Gai
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
/* for sched_param.c */
#include <sched.h>
void *low(void *arg)
{
printf("LOW priority thread!!!\n");
return NULL;
}
void *medium(void *arg)
{
int i,j;
for (i=0; i<300; i++) {
for (j=0; j<1000000; j++) ;
printf((char *)arg);
}
return NULL;
}
void my_create(int policy)
{
pthread_t th1, th2, th3;
pthread_attr_t medium_attr, low_attr;
struct sched_param medium_policy, low_policy;
pthread_attr_init(&medium_attr);
pthread_attr_setinheritsched(&medium_attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&medium_attr, policy);
medium_policy.sched_priority = 2;
pthread_attr_setschedparam(&medium_attr, &medium_policy);
pthread_attr_init(&low_attr);
pthread_attr_setinheritsched(&medium_attr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&low_attr, SCHED_FIFO);
low_policy.sched_priority = 1;
pthread_attr_setschedparam(&low_attr, &low_policy);
pthread_create(&th1, &medium_attr, medium, (char *)".");
pthread_create(&th2, &medium_attr, medium, (char *)"#");
pthread_create(&th3, &low_attr, low, NULL);
pthread_attr_destroy(&medium_attr);
pthread_attr_destroy(&low_attr);
pthread_join(th1, NULL);
pthread_join(th2, NULL);
pthread_join(th3, NULL);
}
void *high(void *arg)
{
/* first experiment:
- two medium priority thread scheduled with RR
- one low priority thread scheduled with FIFO
*/
my_create(SCHED_RR);
/* second experiment:
- two medium priority thread scheduled with FIFO
- one low priority thread scheduled with FIFO
*/
my_create(SCHED_FIFO);
return NULL;
}
int main()
{
pthread_t mythread;
pthread_attr_t myattr;
struct sched_param myparam;
int err;
int parameter;
void *returnvalue;
/* initializes the thread attribute */
pthread_attr_init(&myattr);
pthread_attr_setinheritsched(&myattr, PTHREAD_EXPLICIT_SCHED);
pthread_attr_setschedpolicy(&myattr, SCHED_FIFO);
myparam.sched_priority = 3;
pthread_attr_setschedparam(&myattr, &myparam);
err = pthread_create(&mythread, &myattr, high, (void *)¶meter);
if (err) {
perror("ERROR");
exit(1);
}
pthread_attr_destroy(&myattr);
/* wait the end of the thread we just created */
pthread_join(mythread, &returnvalue);
return 0;
}
next prev parent reply other threads:[~2005-12-10 11:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-09 14:33 [Xenomai-help] Xenomai 2.0.1 - Posix Skin - realtime priorities - what I'm doing wrong? Paolo Gai
2005-12-09 15:50 ` Ulrich Schwab
2005-12-09 18:05 ` Gilles Chanteperdrix
2005-12-09 20:20 ` Paolo Gai
2005-12-09 21:29 ` Gilles Chanteperdrix
2005-12-10 10:53 ` Paolo Gai
2005-12-10 11:14 ` Paolo Gai [this message]
2005-12-11 21:34 ` Gilles Chanteperdrix
2005-12-09 15:58 ` [Xenomai-help] Boot problem V2.0.1 with Kernel 2.6.12 Stephan Zimmermann
2005-12-10 10:55 ` Philippe Gerum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=439AB897.1020304@domain.hid \
--to=pj@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.