Re: wakeup a rt thread.

Der Herr Hofrat <[email protected]> Tue, 15 Feb 2005 13:33:33 +0100 (CET)
Newsgroups gmane.linux.real-time.rtlinux.general
Message-ID <[email protected]>
> 
> Hi all...
> 
> 
>  is there a difference in waking up a rt-thread using the
> 
> 	pthread_wakeup_np(threadx)
> 
> instruction and doing the same with the
> 
>         pthread_kill(threadx, RTL_SIGNAL_WAKEUP);      
>  
> 
> instruction ? If I'm not wrong, the first one calls immediatly the
> scheduler... is the same for the second ?

yup - pthread_wakeup_np calls the scheduler imediately wereas pthread_kill
only marks the signal pending and continues. 

pthread_wakeup_np actually is just a wrapper to:

	pthread_kill(,RTL_SiGNAL_WAKEUP);
	rtl_schedule(); 

which is the same thing as the POSIX way for imediate signal delivery:
	
	pthread_kill(,RTL_SiGNAL_WAKEUP);
	pthread_yield();

And in many cases you want to do 

	pthread_kill(,RTL_SiGNAL_WAKEUP);
	pthread_yield();
	pthread_testcancel();

to ensure handling of pending singals.

Using the POSIX semantics is the better way of doing it simply because
its a well defined API and documented - you will find this scheme in 
books on POSIX threads .

hofrat
_______________________________________________
Rtl mailing list
[email protected]
http://www2.fsmlabs.com/mailman/listinfo/rtl