All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Dmitry Adamushko <dmitry.adamushko@domain.hid>
Cc: Jan Kiszka <jan.kiszka@domain.hid>, Xenomai help <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the
Date: Thu, 21 Dec 2006 14:26:34 +0100	[thread overview]
Message-ID: <458A8B8A.8060401@domain.hid> (raw)
In-Reply-To: <b647ffbd0612210450r4e515046v4eb69da0f6c6c0b3@domain.hid>

Dmitry Adamushko wrote:
> On 21/12/06, Jan Kiszka <jan.kiszka@domain.hid> wrote:
> 
>>Gilles Chanteperdrix wrote:
> 
> ...
> 
>>>>static void realtimetask(void *arg)
>>>>{
>>>>    system("ls -l");
>>>
>>>If you want to use system (or any function calling fork, eg popen or
>>>vfork) with Xenomai, you have to make sure to fault all pages mapped
>>>with write permission after the fork before trying to use services in
>>>priimary mode, because fork write protects all pages with write
>>>permission and notably the threads stacks. A piece of code that faults
>>>all pages follows.
>>
>>Let me check if I got this correctly: fork calls mark all pages
>>write-protected - also those of the father process, or only those of the
>>new child?
> 
> 
> It's copy-on-write policy. fork() creates a separate address space for
> a child (vm_struct, vm_area(s), all the page tables) but it still
> points to the same physical pages as parent's address space. Now what
> if either a child or parent want to modify writeable pages? That's why
> copy-on-write. A new page will be allocated when a write request is
> commited. And yep, to address this issue, the vm areas of (in fact,
> related areas in page tables) both parent and child are marked as
> copy-on-write.
> 
> But I don't think this is an issue here :
> 
> 1) by the moment system() returns -> the child has finished and there
> is no need to allocate new pages on parent's write requests (not sure
> how linux handles it - have to check);

After the fork and the child has returned, the pages remain write
protected. A fault that would occur after that would do almost nothing,
but still causes a migration to secondary mode.

> 
> 2) (I'd expect logically) the parent did mlockall() in advance for
> even future allocations, so I'd expect copy-on-write is not applicable
> fot it -> all the pages should have been duplicated for a child. Well,
> it's a brief idea. Have to check.

I have checked, mlockall has no effect on copy-on-write.

> 
> so it's likely that it's just a side - effect.
> 
> Mathias: if printf() helps (after system()) so could you try e.g.
> fopen(), fclose() instead? Also, please, do what previously was
> suggested with rt_task_delete(NULL) at the end.
> 
> Another situation would be if one does fork() in real-time app. and
> then both parent and child continue their execution (worth checking).
> 
> p.s. vfork() is a different beast. Here a child is supposed to call
> exec*() rigth after fork() so it's allowed to "borrow" parent's
> address space (vm_struct -> all vm_area(s)) and the parent is blocked
> in the mean time. As a result, no need for copy-on-write.

I think to remember that glibc vfork is just fork.

-- 
                                                 Gilles Chanteperdrix


  reply	other threads:[~2006-12-21 13:26 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19  7:54 [Xenomai-help] NMI watchdog: Loading of xeno_native leads to reboot of PC M. Koehrer
2006-12-19  8:08 ` Jan Kiszka
2006-12-19  8:14   ` Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to M. Koehrer
2006-12-19  8:29     ` Jan Kiszka
2006-12-19  8:59       ` Aw: " M. Koehrer
2006-12-19  9:26         ` [Xenomai-help] NMI watchdog: Loading of xeno_native leads M. Koehrer
2006-12-19  9:36           ` Jan Kiszka
2006-12-19 12:04             ` Aw: " M. Koehrer
2006-12-19 13:05               ` Gilles Chanteperdrix
2006-12-19 13:07               ` Jan Kiszka
2006-12-19 14:13                 ` Aw: " M. Koehrer
2006-12-20 13:25                 ` [Xenomai-help] A fairly small rtnet/Xenomai application that freezes the PC M. Koehrer
2006-12-20 13:58                   ` [Xenomai-help] " Jan Kiszka
2006-12-20 14:11                     ` [Xenomai-help] Aw: " M. Koehrer
2006-12-21  8:48                       ` [Xenomai-help] Re: Re: A fairly small rtnet/Xenomai application that freezes the M. Koehrer
2006-12-21  9:03                         ` [Xenomai-help] " Jan Kiszka
2006-12-21 10:21                           ` M. Koehrer
2006-12-21 10:45                             ` Dmitry Adamushko
2006-12-21 11:19                               ` [Xenomai-help] " M. Koehrer
2006-12-21 11:28                                 ` Philippe Gerum
2006-12-21 11:51                                   ` [Xenomai-help] Re: Re: Re: A fairly small rtnet/Xenomai M. Koehrer
2006-12-21 13:09                                     ` Dmitry Adamushko
2006-12-21 13:36                                       ` [Xenomai-help] " M. Koehrer
2006-12-21 14:13                                         ` Philippe Gerum
2006-12-21 15:00                                           ` [Xenomai-help] " M. Koehrer
2006-12-21 15:17                                             ` Dmitry Adamushko
2006-12-21 15:36                                               ` [Xenomai-help] " M. Koehrer
2006-12-21 15:43                                                 ` Dmitry Adamushko
2006-12-21 18:18                                                   ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-22  9:06                                                     ` [Xenomai-help] " M. Koehrer
2006-12-22  9:24                                                       ` Dmitry Adamushko
2006-12-22  9:24                                                       ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-22  9:38                                                         ` [Xenomai-help] " M. Koehrer
2006-12-22  9:40                                                         ` [Xenomai-help] " Dmitry Adamushko
2006-12-22 10:15                                                           ` Gilles Chanteperdrix
2006-12-22 10:27                                                             ` [Xenomai-help] " M. Koehrer
2006-12-22 10:42                                                               ` Dmitry Adamushko
2006-12-22 11:20                                                               ` Philippe Gerum
2006-12-22 11:40                                                                 ` [Xenomai-help] " M. Koehrer
2006-12-22 12:09                                                                   ` Philippe Gerum
2006-12-27  9:25                                                                   ` [Xenomai-help] " Gilles Chanteperdrix
2006-12-27  9:29                                                                     ` [Xenomai-help] Aw: " M. Koehrer
2006-12-27 10:44                                                                     ` [Xenomai-help] " Philippe Gerum
2007-01-02  8:23                                                                       ` M. Koehrer
2007-01-02  9:53                                                                         ` Philippe Gerum
2007-01-02 14:09                                                                           ` Niklaus Giger
2007-01-04 20:57                                                                           ` Niklaus Giger
2007-01-05 10:57                                                                             ` Philippe Gerum
2006-12-27 17:32                                                                     ` [Xenomai-help] COW-disable patch Philippe Gerum
2006-12-22 11:03                                                             ` [Xenomai-help] Re: A fairly small rtnet/Xenomai Jan Kiszka
2006-12-21 15:19                                           ` [Xenomai-help] Re: Re: Re: " M. Koehrer
2006-12-21 16:50                                             ` Jan Kiszka
2006-12-21 16:54                                             ` Philippe Gerum
2006-12-21 17:13                                         ` [Xenomai-help] " Jan Kiszka
2006-12-21 17:47                                           ` Jan Kiszka
2006-12-21 10:53                             ` [Xenomai-help] Re: A fairly small rtnet/Xenomai application that freezes the Gilles Chanteperdrix
2006-12-21 11:35                               ` [Xenomai-help] " M. Koehrer
2006-12-21 12:14                                 ` M. Koehrer
2006-12-21 11:35                               ` [Xenomai-help] " Jan Kiszka
2006-12-21 12:50                                 ` Dmitry Adamushko
2006-12-21 13:26                                   ` Gilles Chanteperdrix [this message]
2006-12-21 14:45                                     ` Gilles Chanteperdrix
2006-12-21 15:12                                       ` Dmitry Adamushko
2006-12-22  9:19                                 ` Gilles Chanteperdrix
2006-12-21 12:48                             ` Jan Kiszka
2006-12-19  9:26         ` Aw: Re: [Xenomai-help] NMI watchdog: Loading of xeno_native leads to Jan Kiszka

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=458A8B8A.8060401@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=dmitry.adamushko@domain.hid \
    --cc=jan.kiszka@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.