All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] rt_task_add_hook() doesnt work
@ 2009-02-12 14:33 Thiago Lima
  2009-02-12 18:09 ` Philippe Gerum
  0 siblings, 1 reply; 3+ messages in thread
From: Thiago Lima @ 2009-02-12 14:33 UTC (permalink / raw)
  To: xenomai

[-- Attachment #1: Type: text/plain, Size: 750 bytes --]

Hi all !

I need to do some things when a new rt task starts. So that, i need to use
the 'rt_task_add_hook()', defined in xenomai task management service.
So, i have created a linux kernel module in which i call this service in
init_module() function. After that, initialize the module and starts a RT
Task.

But, the hook function isnt called. Does anybody have already faced this
problem ?


--------- kernel module simple code -----

void hook(void *cookie) {
   printk(KERN_INFO "hook().\n");
}

int init_module (void) {
    rt_task_add_hook(T_HOOK_START, &hook);
    return 0;
}

--------- kernel module simple code -----


-- 
Thiago Lima Silva
Graduando - Ciência da Computação UFBA
Registered Linux user #466887

[-- Attachment #2: Type: text/html, Size: 873 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai-help] rt_task_add_hook() doesnt work
  2009-02-12 14:33 [Xenomai-help] rt_task_add_hook() doesnt work Thiago Lima
@ 2009-02-12 18:09 ` Philippe Gerum
  2009-02-12 21:17   ` Philippe Gerum
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Gerum @ 2009-02-12 18:09 UTC (permalink / raw)
  To: Thiago Lima; +Cc: xenomai

Thiago Lima wrote:
> Hi all !
> 
> I need to do some things when a new rt task starts. So that, i need to
> use the 'rt_task_add_hook()', defined in xenomai task management service.
> So, i have created a linux kernel module in which i call this service in
> init_module() function. After that, initialize the module and starts a
> RT Task.
> 
> But, the hook function isnt called. Does anybody have already faced this
> problem ?
>

Start hooks are not fired for userland tasks.

> 
> --------- kernel module simple code -----
> 
> void hook(void *cookie) {
>    printk(KERN_INFO "hook().\n");
> }
> 
> int init_module (void) {
>     rt_task_add_hook(T_HOOK_START, &hook);
>     return 0;
> }
> 
> --------- kernel module simple code -----
> 
> 
> -- 
> Thiago Lima Silva
> Graduando - Ciência da Computação UFBA
> Registered Linux user #466887
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Xenomai-help mailing list
> Xenomai-help@domain.hid
> https://mail.gna.org/listinfo/xenomai-help


-- 
Philippe.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Xenomai-help] rt_task_add_hook() doesnt work
  2009-02-12 18:09 ` Philippe Gerum
@ 2009-02-12 21:17   ` Philippe Gerum
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe Gerum @ 2009-02-12 21:17 UTC (permalink / raw)
  To: Thiago Lima; +Cc: xenomai

Philippe Gerum wrote:
> Thiago Lima wrote:
>> Hi all !
>>
>> I need to do some things when a new rt task starts. So that, i need to
>> use the 'rt_task_add_hook()', defined in xenomai task management service.
>> So, i have created a linux kernel module in which i call this service in
>> init_module() function. After that, initialize the module and starts a
>> RT Task.
>>
>> But, the hook function isnt called. Does anybody have already faced this
>> problem ?
>>
> 
> Start hooks are not fired for userland tasks.
>

And there is no valid reason for this. This patch should plug the hole:

--- ksrc/nucleus/pod.c	(revision 4617)
+++ ksrc/nucleus/pod.c	(working copy)
@@ -844,8 +844,8 @@
 	if (xnthread_test_state(thread, XNSHADOW)) {
 		xnlock_put_irqrestore(&nklock, s);
 		xnshadow_start(thread);
-		xnpod_schedule();
-		return 0;
+		xnlock_get_irqsave(&nklock, s);
+		goto callout;
 	}
 #endif /* CONFIG_XENO_OPT_PERVASIVE */

@@ -861,7 +861,8 @@
 		nkpod->schedhook(thread, XNREADY);
 #endif /* __XENO_SIM__ */

-	if (!emptyq_p(&nkpod->tstartq) && !xnthread_test_state(thread, XNROOT)) {
+ callout:
+	if (!emptyq_p(&nkpod->tstartq)) {
 		trace_mark(xn_nucleus_thread_callout,
 			   "thread %p thread_name %s hook %s",
 			   thread, xnthread_name(thread), "START");

>> --------- kernel module simple code -----
>>
>> void hook(void *cookie) {
>>    printk(KERN_INFO "hook().\n");
>> }
>>
>> int init_module (void) {
>>     rt_task_add_hook(T_HOOK_START, &hook);
>>     return 0;
>> }
>>
>> --------- kernel module simple code -----
>>
>>
>> -- 
>> Thiago Lima Silva
>> Graduando - Ciência da Computação UFBA
>> Registered Linux user #466887
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Xenomai-help mailing list
>> Xenomai-help@domain.hid
>> https://mail.gna.org/listinfo/xenomai-help
> 
> 


-- 
Philippe.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-12 21:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-12 14:33 [Xenomai-help] rt_task_add_hook() doesnt work Thiago Lima
2009-02-12 18:09 ` Philippe Gerum
2009-02-12 21:17   ` Philippe Gerum

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.