All of lore.kernel.org
 help / color / mirror / Atom feed
From: "M. Koehrer" <mathias_koehrer@domain.hid>
To: gilles.chanteperdrix@xenomai.org, mathias_koehrer@domain.hid
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] posix functions for real time and non real time
Date: Tue, 8 Jan 2008 12:39:54 +0100 (CET)	[thread overview]
Message-ID: <24653876.1199792394399.JavaMail.ngmail@domain.hid> (raw)
In-Reply-To: <2ff1a98a0801080223l4c975df8qbc64c164b9697454@domain.hid>

Hi Gilles,

thank you very much for the response.
I tried this out and found one strange thing:
When I run the following simple example (that uses the __real_pthread_ functions)
the executable appears in the /proc/xenomai/stat list.
As I am calling __real_pthread_create() I expected that my program does not appear
in xenomai at all.
Build is done using xeno-config --posix-cflags plus -O2 -Wall. For linking xeno-config --posix-ldflags 
is used.

Another question:
Is there a special header file available that has some defines to map the pthread_xxx
function to __real_pthread_xxx.
By including this header I do not have to modify the C code of that files that should
use the non real-time functions.

Thanks for any response on that.

Regards

Mathias

-------------- BEGIN OF CODE ---------------
#include <stdio.h>
#include <sys/mman.h>
#include <pthread.h>

#define USE_REAL
pthread_t thread;

void *mytaska(void *cookie)
{
    int i;
    for (i=0; i < 5; i++)
    {
        struct timespec rqtp;
        printf("Task A\n");
        rqtp.tv_sec = 1;
        rqtp.tv_nsec = 0;
#ifdef USE_REAL
        __real_nanosleep(&rqtp, 0);
#else
        nanosleep(&rqtp, 0);
#endif
    }
    return 0;
}

int main(void)
{
    int i;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    printf("pid: %i\n", getpid());
#ifdef USE_REAL
    __real_pthread_create(&thread, NULL, mytaska, NULL);
#else
    pthread_create(&thread, NULL, mytaska, NULL);
#endif
    for (i=0; i<3; i++)
    {
        struct timespec rqtp;
        printf("Main\n");
        rqtp.tv_sec = 1;
        rqtp.tv_nsec = 0;
#ifdef USE_REAL
        __real_nanosleep(&rqtp, 0);
#else
        __nanosleep(&rqtp, 0);
#endif
    }
    pthread_join(thread, NULL);
    printf("Main: A joined\n");
    return 0;
}
------------- END OF CODE ----------


> On Jan 8, 2008 8:17 AM, M. Koehrer <mathias_koehrer@domain.hid> wrote:
> > Hi everybody,
> >
> > I have a fairly huge application that consists of several real time
> threads and several non real time (posix) threads.
> > For the non real time threads I use the pthread_create function and e.g.
> the pthread_mutex_lock/unlock functions to
> > synchronize them.
> > Is it possible to use the Xenomai Posix skin for real time threads as
> well?
> > When linking against pthread_rt and pthread I have two "variants" of e.g.
> pthread_create. One to be used for real
> > time threads and one for the non real time threads. How are they
> distinguished?
> > How can I define to create a real time task using pthread_create and how
> can I define to create a non real time task
> > using pthread_create.
> 
> In fact, linking agains pthread_rt is not enough to use Xenomai posix
> skin real-time services, in order to get the real-time pthread_create,
> you have to add to the link flags of your application
> -Wl,--wrap,pthread_create. Note that you do not have to pass the
> --wrap yourself, xeno-config --posix-ldflags will pass all the --wrap
> flags.
> 
> Once you pass the -Wl,--wrap,pthread_create to gcc, all calls to
> pthread_create in your code are replaced with calls to
> __wrap_pthread_create, and all calls to __real_pthread_create are
> replaced with calss to the original, non wrapped, pthread_create.
> 
> So, when an application is compiled for Xenomai posix skin, the
> pthread_* services are the real-time services, and the
> __real_pthread_* services are non real-time services.
> 


-- 
Mathias Koehrer
mathias_koehrer@domain.hid


Viel oder wenig? Schnell oder langsam? Unbegrenzt surfen + telefonieren
ohne Zeit- und Volumenbegrenzung? DAS TOP ANGEBOT FÜR ALLE NEUEINSTEIGER
Jetzt bei Arcor: günstig und schnell mit DSL - das All-Inclusive-Paket
für clevere Doppel-Sparer, nur  29,95 Euro  inkl. DSL- und ISDN-Grundgebühr!
http://www.arcor.de/rd/emf-dsl-2


  reply	other threads:[~2008-01-08 11:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  7:17 [Xenomai-help] posix functions for real time and non real time threads M. Koehrer
2008-01-08 10:23 ` Gilles Chanteperdrix
2008-01-08 11:39   ` M. Koehrer [this message]
2008-01-08 12:47     ` [Xenomai-help] posix functions for real time and non real time Jan Kiszka
2008-01-08 13:18       ` Gilles Chanteperdrix
2008-01-08 13:28         ` Gilles Chanteperdrix
2008-01-08 13:44         ` Jan Kiszka
2008-01-08 13:46           ` Gilles Chanteperdrix
2008-01-08 13:58             ` Jan Kiszka
2008-01-08 14:41               ` Philippe Gerum
2008-01-08 15:09                 ` Jan Kiszka
2008-01-08 15:50                   ` Philippe Gerum
2008-01-08 16:11                     ` Gilles Chanteperdrix
2008-01-08 17:10                       ` Philippe Gerum
2008-01-08 17:41                         ` Gilles Chanteperdrix
2008-01-08 15:01     ` Gilles Chanteperdrix

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=24653876.1199792394399.JavaMail.ngmail@domain.hid \
    --to=mathias_koehrer@domain.hid \
    --cc=gilles.chanteperdrix@xenomai.org \
    --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.