On Fri, Oct 27, 2000 at 05:03:44PM +0200, Pavel Andris wrote:
> Hi Chuck and all,
> 
> On Fri, Oct 27, 2000 at 10:48:58AM -0400, [EMAIL PROTECTED] wrote:
> > 
> > > I believe it is correct. If you call pthread_create() from init_module(),
> > > the newly created RTthread starts running _immediately_ and you may be
> > > unsure when the init_module() will be finished. This means, finishing
> > > init_module() depends on when the RTthread gives up CPU. 
> > > Regards, pa
> > 
> > Yes, as I said, I agree in theory. But I just tried switching it around in
> > some code of mine so that I call pthread_setfp_np just before I call
> > pthread_create, and I get a seg fault, my thread doesn't work, and it
> > can't be remove. I'm about to reboot to get rid of it.
> > 
> > Setup the other way (ie. with pthread_setfp_np just after pthread_create)
> > my periodic thread runs fine, correctly calling some >100 floating point
> > functions from math.h every 100 micro seconds. [For those concerned, the
> > seg fault occurred when I was running a scaled down code, calling only
> > 10 fp math.h fxns each 200 micro seconds, - a very minimal load thread.]
> > 
> > So why does it work when I do it wrong, but not when I do it right?
> > Anyone? (dmesg output below for those who can read it)
> 
> BTW, I've never recommended to call pthread_setfp_np before or after
> pthread_create() (in init_module()). I've recommended: "Try to put
> your pthread_setfp_np call as the first statement in your RTthread."

POSIX requires that a newly created thread start running at once, so 
         creat
         set_fp
is not good since the thread may have already executed fp operations.
As Pavel says, the correct method is

thread_code{
             set_fp  /*before we do any fp ops */
       ...
      }

and then in the init code
       creat_thread

The alternative method, which is more POSIX-ly correct is to use
       pthread_attr_setfp

during the thread creation --  before the create call.
But since I just noticed that this call is not in the man pages yet, I'm 
not surprised that nobody saw it. sorry.


> 
> Maybe it's time for a word from RTL gurus.
> 
> Regards,
> 
> pa
> 
> -- 
> ..........................................................................
> Pavel Andris                               | tel: +421 7 5941 2167
> Institute of Control Theory and Robotics   | fax: +421 7 5477 6045
> Slovak Academy of Sciences                 | 
> Dubravska cesta 9                          | e-mail: [EMAIL PROTECTED]
> SK - 842 37 Bratislava                     |
> Slovakia                                   |
> .........................................................................
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> ---
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/rtlinux/

-- 
---------------------------------------------------------
Victor Yodaiken 
Finite State Machine Labs: The RTLinux Company.
 www.fsmlabs.com  www.rtlinux.com

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
---
For more information on Real-Time Linux see:
http://www.rtlinux.org/rtlinux/

Reply via email to