All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@domain.hid>
To: "oliver.schlenker@domain.hid" <oliver.schlenker@domain.hid>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai-help] :: rt_printf with daemonized task
Date: Thu, 08 Oct 2009 15:17:08 +0200	[thread overview]
Message-ID: <4ACDE654.9010200@domain.hid> (raw)
In-Reply-To: <0000ACCF.4ACDF0A2@domain.hid>

oliver.schlenker@domain.hid wrote:
> 
> 
> 
> 
> -------- Original Message --------
> Subject: Re: Re : rt_printf with daemonized task (08-Okt-2009 12:16)
> From:    Jan Kiszka <jan.kiszka@domain.hid>
> To:      oliver.schlenker@domain.hid
> 
>> Gilles Chanteperdrix wrote:
>>> Jan Kiszka wrote:
>>>> Gilles Chanteperdrix wrote:
>>>>> oliver.schlenker@domain.hid wrote:
>>>>>>>> int main( int arc, char *argv[] ) { int i;
>>>>>>>>
>>>>>>>> rt_print_auto_init(1);
>>>>>>>>
>>>>>>>> rt_printf("--------------- TEST RT-PRINTF  1 ------------\n");
>>>>>>>>
>>>>>>>> sleep(1);
>>>>>>>>
>>>>>>>> daemon(0,0);
>>>>>>>>
>>>>>>>> rt_print_auto_init(1);
>>>>>> Ok, understood, at least for the scenario where the rt_print feature
>>>>>> is initialised befor the fork/daemon call. What I don't understand
>>>>>> is, why it does not work if the rt_print feature is initialised after
>>>>>> the fork / daemon.
>>>>> From the way I understand your code, you never tried to initialize the
>>>>> rt_print feature only after the fork, your code initializes it both
>>>>> before and after.
>>>>>
>>>> There are two initializations: The base init done via __rt_print_init on
>>>> library loading and the one to be done per-thread via rt_print_init (or
>>>> on first rt_printf). That printer thread is initialized via the former
>>>> one. On fork, we do not need to re-run the full __rt_print_init
>>>> (variables and resources are cloned on fork), we just need to spawn
>>>> another printer thread.
>>> Unless I am wrong, rtdk also maintains a list of the thread buffers
>>> which need to be polled. After the fork, this list will be intact, but
>>> the threads to which belong the buffers will no longer exist. So, IMO,
>>> the fork handler should also free all these buffers and reset the list
>>> to the empty state.
>> Famous last words: That should work without tweaking. A print_buffer
>> only contains data references, nothing that points to some uncloned thread.
>>
>> Jan
>>
>> -- 
>> Siemens AG, Corporate Technology, CT SE 2
>> Corporate Competence Center Embedded Linux
> 
> To have a fork save rtprint library it's necessary to
> 
> 1. Reset rtdk thread buffer list
>    
>     I have no idea where to look at for the rtdk thread buffer list. Inside rt_print.c ?

It's all there, it's called first_buffer. Just walk that list and call
cleanup_buffers on the entries.

>    
> 2. Spawning another printer thread
>     with code like :
> 	pthread_attr_init(&thattr);
> 	pthread_attr_setstacksize(&thattr, PTHREAD_STACK_MIN);
> 	pthread_create(&__printer_thread, &thattr, printer_loop, NULL); 
> 
> 
> Is there anything else to do ?
> 

Probably not, but I was already wrong before. :)

> 
> I'm also planning to add a function to the lib like :
> 
> rt_print_to_syslog( int priority )

Better provide some rt_syslog(int priority, char *format, ...),
corresponding to the standard service.

Jan

-- 
Siemens AG, Corporate Technology, CT SE 2
Corporate Competence Center Embedded Linux


  reply	other threads:[~2009-10-08 13:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-08 12:01 [Xenomai-help] :: rt_printf with daemonized task oliver.schlenker
2009-10-08 13:17 ` Jan Kiszka [this message]
  -- strict thread matches above, loose matches on Subject: below --
2009-10-20 10:03 oliver.schlenker
2009-10-20 16:01 ` Gilles Chanteperdrix
2009-10-20 16:07   ` Jan Kiszka
2009-10-20 16:11 ` Jan Kiszka
2009-10-20  9:26 oliver.schlenker
2009-10-20  9:33 ` Jan Kiszka
2009-10-19 13:14 oliver.schlenker
2009-10-19 14:00 ` Jan Kiszka
2009-10-19 13:12 oliver.schlenker
2009-10-19 14:00 ` Jan Kiszka
2009-10-09 14:48 oliver.schlenker
2009-10-09 14:59 ` Jan Kiszka
2009-10-09 13:54 oliver.schlenker
2009-10-09 13:34 oliver.schlenker
2009-10-09 13:49 ` Gilles Chanteperdrix
2009-10-09 13:58 ` Jan Kiszka
2009-10-08  7:15 [Xenomai-help] " oliver.schlenker
2009-10-06 15:10 oliver.schlenker
2009-10-06 15:16 ` 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=4ACDE654.9010200@domain.hid \
    --to=jan.kiszka@domain.hid \
    --cc=oliver.schlenker@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.