Hi,
The reason that I have not given this piece of code was because it is not
written by me oflate but was code that exists since several years which is
running on VxWorks on different versions.
I just ported this with very very minimal effort to Linux over Xenomai. It is
also huge code base and several dependencies.
In VxWorks we ran our code in Kernel space and not in user space we used lot
of global data as well.
So therefore on Linux, I tied the several tasks that are being spawned into
single process on Linux because of dependency and data being shared.
What ever I can explain, I explained over the last email about those tasks in
gist.
I can also give bit more information after you look at the code snippet.
Please just search for string "README" in these files where I gave my
observations.
I hope this is one last issue on my table to solve it in whole porting and
running our legacy VxWorks code on Linux.
Samba
-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Thursday, 01. September, 2011 14:06
To: Sambasiva Rao Manchili
Cc: [email protected]
Subject: Re: [Xenomai-help] taskDelete(tid) on VxWorks Skin ?
On 09/01/2011 02:01 PM, Sambasiva Rao Manchili wrote:
> Hi,
>
> Version info is as follows
> Linux eup1 2.6.37.6_xenomai-2.5.6 #2 PREEMPT Mon Jul 18 21:08:17 CEST
> 2011 i686 i686 i386 GNU/Linux
>
> Kernel Configuraiton attached.
>
> Actually the task that was deleted was "do_forth" task(running at priority
> 143) by Terminator task(priority 97).
> Terminator task also exited.
You missed section 4 in the page I sent you. This is the most important item.
--
Gilles.
This email and any attachment may contain confidential information which is
intended for use only by the addressee(s) named above. If you received this
email by mistake, please notify the sender immediately, and delete the email
from your system. You are prohibited from copying, disseminating or otherwise
using the email or any attachment.
extern int create_forth_task(SCENTABLE_ENTRY_TYPE *entry,
int priority,
int special_stack_size)
{
char name[40];
int used_stack_size;
pthread_t doForthTaskId;
int task_id;
used_stack_size = (special_stack_size != 0) ? special_stack_size : (160 *
1024) ;
sprintf(name,"tForth%d",entry->toffset);
task_id = taskSpawn(name,
priority,
0,
used_stack_size,
(FUNCPTR)do_forth,
(int) entry->config_ptr,
(int) entry->dict_ptr,
(int)entry->toffset,0,0,0,0,0,0,0);
if (task_id == ERROR)
{
serr_log(SERR_ERROR,"cannot spawn tForth (%s)",
strerror(errnoGet()));
return 1;
}
return task_id; /* README:- Usually I see here Xenomai returns task_id as
two or three digit number*/
}static void terminator_task(TASK_TAB_TYPE *task_listp, int termNo)
{
UINT_16 i, number;
SCENTABLE_ENTRY_TYPE *entry;
TESA_CNTRL_TYPE msg;
STATUS status;
TOffset toffset;
char name[40];
struct timespec ts;
sprintf(name,"tTerminator%d",termNo);
logOpen(name);
serr_open2("tesa",SERR_LDF,0,&tesa_data_fieldp->tesa_ldf_vals);
ts.tv_sec = 0;
ts.tv_nsec = 50000; /* 50 ms */
msg.msgtype = TESA_FORTH_CNTRL;
msg.data = (task_listp->control == KILL_FORTH) ? FS_KILLED : FS_RELEASED;
number = task_listp->anzahl;
printf("%s: Number---><%d>\n",__FUNCTION__, number);
while (number) {
for (i = 0; i < task_listp->anzahl; i++) {
if ((toffset = task_listp->toffset[i])) {
entry = &tesa_scentablep[toffset];
taskSuspend(task_listp->token[i]); /* README Tried with suspend did
not help */
/* README , as taskDelete did not work, I tried with force but did not
help either.
* The value of TaskID that I pass here as parameter to taskDelete is
taskDeleteForce
* is same as what I got from taskSpawn from Xenomai.
*/
status = taskDeleteForce(task_listp->token[i]);
serr_log(SERR_INFO,"task %x deleted status %d",task_listp->token[i],
status);
if (status == OK) {
/* README XENOMAI Retrusn STATUS OK */
number--;
task_listp->toffset[i] = 0;
msg.termoffset = toffset; /* set terminaloffset in message */
(void) tesa_tx_message(&msg,sizeof(TESA_CNTRL_TYPE));
} else {
/* README NEVER ENTERS HERE */
serrLog( serrWarn, "terminator_task: deletion of tForth%d failed!
%s",
toffset, strerror(errnoGet()) );
/* if errno equal S_objLib_OBJ_UNAVAILABLE: the interpreter is in
a critical region ( taskSave is set ) --> try to delete it later
else we assume that the task is already deleted
*/
if (errnoGet() != S_objLib_OBJ_UNAVAILABLE) {
number--;
task_listp->toffset[i] = 0;
msg.termoffset = toffset; /* set terminaloffset in message */
(void) tesa_tx_message(&msg,sizeof(TESA_CNTRL_TYPE));
}
}
} /* if (toffset) */
} /* for */
taskDelay( 10 );
} /* while (number) */
free(task_listp);
printf("%s: Not Calling Exit\n", __FUNCTION__);
/*pthread_exit(0);
exit(0); Original VxWorks code */
}
static void* thread_TesaItask(void *arg)
{
arg=arg;
logMsg(INFO_0,"Exectuting tesa_itask....");
/* README tesa_itask Should spawn 3 tasks (and one of those 3 tasks spawned
will spawn
* do_forthTask on some event)
* do_forthTask is for ever and will be deleted by terminatorTask which is
spawned by one of those 3 tasks
* during cleanup event.
*
*/
tesa_itask();
printf("%s: Going to sleep INFINITE", __FUNCTION__);
while(1)
{
sleep(3600);
}
return 0;
}
int main(int argc, char **argv)
{
...
...
tesaITask = osCreateDetachedThread(thread_TesaItask,NULL);
logMsg(INFO_0, "%s: Returned from osCreateDetachedThread tesaItask<%ld>",
__FUNCTION__, tesaITask);
....
}_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help