* [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid @ 2008-08-26 9:45 Matthieu 2008-08-26 12:44 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: Matthieu @ 2008-08-26 9:45 UTC (permalink / raw) To: xenomai Hi I would like to understand the coherence between the task identifier of the task control block and the task id given by taskDesk (function taskInfoGet()). In fact, I init a task with taskInit, I get the tid using tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a taskDesk.td_tid different from the tid. I want to test if the task is suspended using taskIsSuspended(tid) or taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by /proc/xenomai/stat also has no connection. Idem with a ps -AfL Thank you in advance for your explanations Matthieu ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid 2008-08-26 9:45 [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid Matthieu @ 2008-08-26 12:44 ` Gilles Chanteperdrix 2008-08-26 12:55 ` Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-08-26 12:44 UTC (permalink / raw) To: matthieu.connaulte_xenomai; +Cc: xenomai Matthieu wrote: > Hi > > I would like to understand the coherence between the task identifier of the > task control block and the task id given by taskDesk (function > taskInfoGet()). In fact, I init a task with taskInit, I get the tid using > tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a > taskDesk.td_tid different from the tid. > > I want to test if the task is suspended using taskIsSuspended(tid) or > taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code > error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by > /proc/xenomai/stat also has no connection. Idem with a ps -AfL > > Thank you in advance for your explanations You are not supposed to use the internal fields of the structures. A valid id is one returned by the taskIdSelf(), taskNameToId(), taskIdDefault(). I can not find a service which returns the task Id for a given TCB. Is it what you are looking for ? -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid 2008-08-26 12:44 ` Gilles Chanteperdrix @ 2008-08-26 12:55 ` Gilles Chanteperdrix 2008-08-26 14:15 ` [Xenomai-help] " Matthieu 0 siblings, 1 reply; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-08-26 12:55 UTC (permalink / raw) To: matthieu.connaulte_xenomai; +Cc: xenomai Gilles Chanteperdrix wrote: > Matthieu wrote: >> Hi >> >> I would like to understand the coherence between the task identifier of the >> task control block and the task id given by taskDesk (function >> taskInfoGet()). In fact, I init a task with taskInit, I get the tid using >> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >> taskDesk.td_tid different from the tid. >> >> I want to test if the task is suspended using taskIsSuspended(tid) or >> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code >> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >> >> Thank you in advance for your explanations > > You are not supposed to use the internal fields of the structures. A > valid id is one returned by the taskIdSelf(), taskNameToId(), > taskIdDefault(). I can not find a service which returns the task Id for > a given TCB. Is it what you are looking for ? By the way, if you could call taskInfoGet, you already have a valid task id... -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Xenomai-help] Re: Problem with tcb.handle and taskDesc.td_tid 2008-08-26 12:55 ` Gilles Chanteperdrix @ 2008-08-26 14:15 ` Matthieu 2008-08-26 14:37 ` [Xenomai-help] " Gilles Chanteperdrix 0 siblings, 1 reply; 9+ messages in thread From: Matthieu @ 2008-08-26 14:15 UTC (permalink / raw) To: xenomai On Tue, 26 Aug 2008 14:55:19 +0200, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > Gilles Chanteperdrix wrote: >> Matthieu wrote: >>> Hi >>> >>> I would like to understand the coherence between the task identifier of > the >>> task control block and the task id given by taskDesk (function >>> taskInfoGet()). In fact, I init a task with taskInit, I get the tid > using >>> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >>> taskDesk.td_tid different from the tid. >>> >>> I want to test if the task is suspended using taskIsSuspended(tid) or >>> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code >>> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >>> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >>> >>> Thank you in advance for your explanations >> >> You are not supposed to use the internal fields of the structures. A >> valid id is one returned by the taskIdSelf(), taskNameToId(), >> taskIdDefault(). I can not find a service which returns the task Id for >> a given TCB. Is it what you are looking for ? > > By the way, if you could call taskInfoGet, you already have a valid task > id... > But using taskNameToId, taskSuspend(tid) makes the same error and so is taskInfoGet(). In the sources, I saw that taskInfoGet seems to be a reentrant routine (see ksrc/skins/vxworks/syscall.c where a taskInfoGet is call in the taskInfoGet routine) Matthieu > -- > Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid 2008-08-26 14:15 ` [Xenomai-help] " Matthieu @ 2008-08-26 14:37 ` Gilles Chanteperdrix 2008-08-27 7:07 ` [Xenomai-help] Re: " Matthieu ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-08-26 14:37 UTC (permalink / raw) To: matthieu.connaulte_xenomai; +Cc: xenomai Matthieu wrote: > > On Tue, 26 Aug 2008 14:55:19 +0200, Gilles Chanteperdrix > <gilles.chanteperdrix@xenomai.org> wrote: >> Gilles Chanteperdrix wrote: >>> Matthieu wrote: >>>> Hi >>>> >>>> I would like to understand the coherence between the task identifier of >> the >>>> task control block and the task id given by taskDesk (function >>>> taskInfoGet()). In fact, I init a task with taskInit, I get the tid >> using >>>> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >>>> taskDesk.td_tid different from the tid. >>>> >>>> I want to test if the task is suspended using taskIsSuspended(tid) or >>>> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code >>>> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >>>> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >>>> >>>> Thank you in advance for your explanations >>> You are not supposed to use the internal fields of the structures. A >>> valid id is one returned by the taskIdSelf(), taskNameToId(), >>> taskIdDefault(). I can not find a service which returns the task Id for >>> a given TCB. Is it what you are looking for ? >> By the way, if you could call taskInfoGet, you already have a valid task >> id... >> > > But using taskNameToId, taskSuspend(tid) makes the same error and so is > taskInfoGet(). Ok. So, we have a bug and these functions do not work as expected. In the sources, I saw that taskInfoGet seems to be a > reentrant routine (see ksrc/skins/vxworks/syscall.c where a taskInfoGet is > call in the taskInfoGet routine) If by reentrant you mean recursive, no, not at all, taskInfoGet is not recursive. You see, the interface between user-space and kernel-space is not a simple function call, it is a system call, that is the way the whole Linux kernel works. The difference between Linux and Xenomai is that Xenomai APIs are symetric between kernel-space and user-space. So, the function implementing a kernel-space service is used to implement the system call used by the user-space service of the same name. What you see in ksrc/skins/vxworks/syscall.c is that the function __wind_task_info_get, which is the handler of the vxworks skin __vxworks_taskinfo_get system call, calls the kernel-space taskInfoGet function, so there is no recursion. in src/skins/vxworks/taskInfo.c, you will see that the taskInfoGet function emits the _vxworks_taskinfo_get system call. -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Xenomai-help] Re: Re: Problem with tcb.handle and taskDesc.td_tid 2008-08-26 14:37 ` [Xenomai-help] " Gilles Chanteperdrix @ 2008-08-27 7:07 ` Matthieu [not found] ` <6001ba171dd65d7fb2e8846949e76d94@domain.hid> 2008-08-27 8:09 ` Philippe Gerum 2 siblings, 0 replies; 9+ messages in thread From: Matthieu @ 2008-08-27 7:07 UTC (permalink / raw) To: xenomai On Tue, 26 Aug 2008 16:37:27 +0200, Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org> wrote: > Matthieu wrote: >> >> On Tue, 26 Aug 2008 14:55:19 +0200, Gilles Chanteperdrix >> <gilles.chanteperdrix@xenomai.org> wrote: >>> Gilles Chanteperdrix wrote: >>>> Matthieu wrote: >>>>> Hi >>>>> >>>>> I would like to understand the coherence between the task identifier > of >>> the >>>>> task control block and the task id given by taskDesk (function >>>>> taskInfoGet()). In fact, I init a task with taskInit, I get the tid >>> using >>>>> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >>>>> taskDesk.td_tid different from the tid. >>>>> >>>>> I want to test if the task is suspended using taskIsSuspended(tid) or >>>>> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno > (code >>>>> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >>>>> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >>>>> >>>>> Thank you in advance for your explanations >>>> You are not supposed to use the internal fields of the structures. A >>>> valid id is one returned by the taskIdSelf(), taskNameToId(), >>>> taskIdDefault(). I can not find a service which returns the task Id > for >>>> a given TCB. Is it what you are looking for ? >>> By the way, if you could call taskInfoGet, you already have a valid > task >>> id... >>> >> >> But using taskNameToId, taskSuspend(tid) makes the same error and so is >> taskInfoGet(). > > Ok. So, we have a bug and these functions do not work as expected. > > In the sources, I saw that taskInfoGet seems to be a >> reentrant routine (see ksrc/skins/vxworks/syscall.c where a taskInfoGet > is >> call in the taskInfoGet routine) > > If by reentrant you mean recursive, no, not at all, taskInfoGet is not > recursive. You see, the interface between user-space and kernel-space is > not a simple function call, it is a system call, that is the way the > whole Linux kernel works. The difference between Linux and Xenomai is > that Xenomai APIs are symetric between kernel-space and user-space. So, > the function implementing a kernel-space service is used to implement > the system call used by the user-space service of the same name. > > What you see in ksrc/skins/vxworks/syscall.c is that the function > __wind_task_info_get, which is the handler of the vxworks skin > __vxworks_taskinfo_get system call, calls the kernel-space taskInfoGet > function, so there is no recursion. > in src/skins/vxworks/taskInfo.c, you will see that the taskInfoGet > function emits the _vxworks_taskinfo_get system call. > > -- > Gilles. Reading that I'm not supposed to use the internal fields of the structures, and using taskInfoGet, I have some doubts about what I'm doing : I get a taskDesc structure and I modify its field td_entry to set the function pointer of the routine (FUNCPTR). I'm not really sure this going to works. On WINDRIVER, I were able to directly modify the field WIND_TCB->entry. What do you thing about this ? Matthieu ^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <6001ba171dd65d7fb2e8846949e76d94@domain.hid>]
* Re: [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid [not found] ` <6001ba171dd65d7fb2e8846949e76d94@domain.hid> @ 2008-08-27 7:09 ` Gilles Chanteperdrix 0 siblings, 0 replies; 9+ messages in thread From: Gilles Chanteperdrix @ 2008-08-27 7:09 UTC (permalink / raw) To: matthieu.connaulte, Xenomai help Matthieu Connaulte wrote: > On Tue, 26 Aug 2008 16:37:27 +0200, Gilles Chanteperdrix > <gilles.chanteperdrix@xenomai.org> wrote: >> Matthieu wrote: >>> On Tue, 26 Aug 2008 14:55:19 +0200, Gilles Chanteperdrix >>> <gilles.chanteperdrix@xenomai.org> wrote: >>>> Gilles Chanteperdrix wrote: >>>>> Matthieu wrote: >>>>>> Hi >>>>>> >>>>>> I would like to understand the coherence between the task identifier >> of >>>> the >>>>>> task control block and the task id given by taskDesk (function >>>>>> taskInfoGet()). In fact, I init a task with taskInit, I get the tid >>>> using >>>>>> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >>>>>> taskDesk.td_tid different from the tid. >>>>>> >>>>>> I want to test if the task is suspended using taskIsSuspended(tid) or >>>>>> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno >> (code >>>>>> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >>>>>> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >>>>>> >>>>>> Thank you in advance for your explanations >>>>> You are not supposed to use the internal fields of the structures. A >>>>> valid id is one returned by the taskIdSelf(), taskNameToId(), >>>>> taskIdDefault(). I can not find a service which returns the task Id >> for >>>>> a given TCB. Is it what you are looking for ? >>>> By the way, if you could call taskInfoGet, you already have a valid >> task >>>> id... >>>> >>> But using taskNameToId, taskSuspend(tid) makes the same error and so is >>> taskInfoGet(). >> Ok. So, we have a bug and these functions do not work as expected. >> >> In the sources, I saw that taskInfoGet seems to be a >>> reentrant routine (see ksrc/skins/vxworks/syscall.c where a taskInfoGet >> is >>> call in the taskInfoGet routine) >> If by reentrant you mean recursive, no, not at all, taskInfoGet is not >> recursive. You see, the interface between user-space and kernel-space is >> not a simple function call, it is a system call, that is the way the >> whole Linux kernel works. The difference between Linux and Xenomai is >> that Xenomai APIs are symetric between kernel-space and user-space. So, >> the function implementing a kernel-space service is used to implement >> the system call used by the user-space service of the same name. >> >> What you see in ksrc/skins/vxworks/syscall.c is that the function >> __wind_task_info_get, which is the handler of the vxworks skin >> __vxworks_taskinfo_get system call, calls the kernel-space taskInfoGet >> function, so there is no recursion. >> in src/skins/vxworks/taskInfo.c, you will see that the taskInfoGet >> function emits the _vxworks_taskinfo_get system call. >> >> -- > > Reading that I'm not supposed to use the internal fields of the structures, > and using taskInfoGet, I have some doubts about what I'm doing : I get a > taskDesc structure and I modify its field td_entry to set the function > pointer of the routine (FUNCPTR). I'm not really sure this going to works. > On WINDRIVER, I were able to directly modify the field WIND_TCB->entry. > What do you thing about this ? What do YOU think ? -- Gilles. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid 2008-08-26 14:37 ` [Xenomai-help] " Gilles Chanteperdrix 2008-08-27 7:07 ` [Xenomai-help] Re: " Matthieu [not found] ` <6001ba171dd65d7fb2e8846949e76d94@domain.hid> @ 2008-08-27 8:09 ` Philippe Gerum 2008-08-28 7:00 ` [Xenomai-help] " Matthieu 2 siblings, 1 reply; 9+ messages in thread From: Philippe Gerum @ 2008-08-27 8:09 UTC (permalink / raw) To: Gilles Chanteperdrix; +Cc: xenomai Gilles Chanteperdrix wrote: > Matthieu wrote: >> On Tue, 26 Aug 2008 14:55:19 +0200, Gilles Chanteperdrix >> <gilles.chanteperdrix@xenomai.org> wrote: >>> Gilles Chanteperdrix wrote: >>>> Matthieu wrote: >>>>> Hi >>>>> >>>>> I would like to understand the coherence between the task identifier of >>> the >>>>> task control block and the task id given by taskDesk (function >>>>> taskInfoGet()). In fact, I init a task with taskInit, I get the tid >>> using >>>>> tid=tcb.handle. The use of taskInfoGet(tid, taskDesc) gives me a >>>>> taskDesk.td_tid different from the tid. >>>>> >>>>> I want to test if the task is suspended using taskIsSuspended(tid) or >>>>> taskIsSuspended(taskDesc.td_tid), but both get me a 3d0001 errno (code >>>>> error of WIND_OBJ_ERR_BASE S_objLib_OBJ_ID_ERROR). The PID given by >>>>> /proc/xenomai/stat also has no connection. Idem with a ps -AfL >>>>> >>>>> Thank you in advance for your explanations >>>> You are not supposed to use the internal fields of the structures. A >>>> valid id is one returned by the taskIdSelf(), taskNameToId(), >>>> taskIdDefault(). I can not find a service which returns the task Id for >>>> a given TCB. Is it what you are looking for ? >>> By the way, if you could call taskInfoGet, you already have a valid task >>> id... >>> >> But using taskNameToId, taskSuspend(tid) makes the same error and so is >> taskInfoGet(). > > Ok. So, we have a bug and these functions do not work as expected. > Kernel to userland id. translation was missing for the taskNameToId() wrapper. Index: include/vxworks/vxworks.h =================================================================== --- include/vxworks/vxworks.h (revision 4121) +++ include/vxworks/vxworks.h (working copy) @@ -232,6 +232,8 @@ typedef void (*wind_tick_handler_t)(long); +xnhandle_t taskNameToHandle(const char *name); + #ifdef errno #undef errno #endif Index: ksrc/skins/vxworks/syscall.c =================================================================== --- ksrc/skins/vxworks/syscall.c (revision 4121) +++ ksrc/skins/vxworks/syscall.c (working copy) @@ -411,7 +411,7 @@ { char name[XNOBJECT_NAME_LEN]; WIND_TCB_PLACEHOLDER ph; - TASK_ID task_id; + xnhandle_t handle; if (!__xn_access_ok (curr, VERIFY_WRITE, __xn_reg_arg2(regs), sizeof(ph))) @@ -429,12 +429,11 @@ sizeof(name) - 1); name[sizeof(name) - 1] = '\0'; - task_id = taskNameToId(name); - - if (task_id == ERROR) + handle = taskNameToHandle(name); + if (handle == XN_NO_HANDLE) return wind_errnoget(); - ph.handle = task_id; /* Copy back the task handle. */ + ph.handle = handle; /* Copy back the task handle. */ __xn_copy_to_user(curr, (void __user *)__xn_reg_arg2(regs), &ph, sizeof(ph)); Index: ksrc/skins/vxworks/taskLib.c =================================================================== --- ksrc/skins/vxworks/taskLib.c (revision 4121) +++ ksrc/skins/vxworks/taskLib.c (working copy) @@ -551,9 +551,9 @@ wind_tasks_q */ TASK_ID taskNameToId(const char *name) { + TASK_ID result = (TASK_ID)ERROR; xnholder_t *holder; wind_task_t *task; - int result = ERROR; spl_t s; if (!name) @@ -578,6 +578,28 @@ return result; } +xnhandle_t taskNameToHandle(const char *name) +{ + xnhandle_t handle; + wind_task_t *task; + TASK_ID task_id; + spl_t s; + + xnlock_get_irqsave(&nklock, s); + + task_id = taskNameToId(name); + if (task_id == ERROR) { + handle = XN_NO_HANDLE; + goto out; + } + task = (wind_task_t *)task_id; + handle = xnthread_handle(&task->threadbase); +out: + xnlock_put_irqrestore(&nklock, s); + + return handle; +} + /* nklock must be locked on entry, interrupts off */ static int testSafe(wind_task_t *task) { -- Philippe. ^ permalink raw reply [flat|nested] 9+ messages in thread
* [Xenomai-help] Re: Problem with tcb.handle and taskDesc.td_tid 2008-08-27 8:09 ` Philippe Gerum @ 2008-08-28 7:00 ` Matthieu 0 siblings, 0 replies; 9+ messages in thread From: Matthieu @ 2008-08-28 7:00 UTC (permalink / raw) To: xenomai I tested the patch. TaskInfoGet works. It gives me a taskDesc.td_tid different from tid given by taskNameToId, but I don't known if there is any relation. I try to know if my task is suspended, but I always have the result 0 from taskIsSuspended(tid) while my task has been initiated but not activated. So I would like to know if a taskInit turn the task in suspended state ? If so, what can be my error ? Matthieu ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-08-28 7:00 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-26 9:45 [Xenomai-help] Problem with tcb.handle and taskDesc.td_tid Matthieu
2008-08-26 12:44 ` Gilles Chanteperdrix
2008-08-26 12:55 ` Gilles Chanteperdrix
2008-08-26 14:15 ` [Xenomai-help] " Matthieu
2008-08-26 14:37 ` [Xenomai-help] " Gilles Chanteperdrix
2008-08-27 7:07 ` [Xenomai-help] Re: " Matthieu
[not found] ` <6001ba171dd65d7fb2e8846949e76d94@domain.hid>
2008-08-27 7:09 ` [Xenomai-help] " Gilles Chanteperdrix
2008-08-27 8:09 ` Philippe Gerum
2008-08-28 7:00 ` [Xenomai-help] " Matthieu
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.