tasks creation with Linux

Garcia Jérémie GARCIAJ at 3il.fr
Sat Jun 19 02:56:30 EST 2004


Hi everybody,
as you guess, I'm looking for some help... Indeed although I am a newbie in Linux system programming, I have to adapt a ppc405 VxWorks application to a Linux Montavista Hardhat application...
My problem is the following ; with VxWorks, a task is defined like that:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
     It is often essential to organize applications into independent, though cooperating, programs. Each of these programs, while executing, is called a task. In VxWorks, tasks have immediate, shared access to most system resources, while also maintaining enough separate context to maintain individual threads of control.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

In my original application, there is a VxWorks routine called taskSpawn(). Below you'll find its man pages:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
NAME

taskSpawn( ) - spawn a task
SYNOPSIS

int taskSpawn
    (
    char *  name,             /* name of new task (stored at pStackBase) */
    int     priority,         /* priority of new task */
    int     options,          /* task option word */
    int     stackSize,        /* size (bytes) of stack needed plus name */
    FUNCPTR entryPt,          /* entry point of new task */
    int     arg1,             /* 1st of 10 req'd task args to pass to func */
    int     arg2,
    int     arg3,
    int     arg4,
    int     arg5,
    int     arg6,
    int     arg7,
    int     arg8,
    int     arg9,
    int     arg10
    )

DESCRIPTION

This routine creates and activates a new task with a specified priority and options and returns a system-assigned ID. See taskInit( ) and taskActivate( ) for the building blocks of this routine.

A task may be assigned a name as a debugging aid. This name will appear in displays generated by various system information facilities such as i( ). The name may be of arbitrary length and content, but the current VxWorks convention is to limit task names to ten characters and prefix them with a "t". If name is specified as NULL, an ASCII name will be assigned to the task of the form "tn" where n is an integer which increments as new tasks are spawned.

The only resource allocated to a spawned task is a stack of a specified size stackSize, which is allocated from the system memory partition. Stack size should be an even integer. A task control block (TCB) is carved from the stack, as well as any memory required by the task name. The remaining memory is the task's stack and every byte is filled with the value 0xEE for the checkStack( ) facility. See the manual entry for checkStack( ) for stack-size checking aids.

The entry address entryPt is the address of the "main" routine of the task. The routine will be called once the C environment has been set up. The specified routine will be called with the ten given arguments. Should the specified main routine return, a call to exit( ) will automatically be made.

Note that ten (and only ten) arguments must be passed for the spawned function.

[etc...]
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

This routine is used as that in my program:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if (nbEnet > 0)
         rc = taskSpawn("serverA", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortA, (int) myconfig, 0,0,0,0,0,0,0,0);
      if (nbEnet > 1)
         rc = taskSpawn("serverB", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortB, (int) myconfig, 0,0,0,0,0,0,0,0);
      if (nbEnet > 2)
         rc = taskSpawn("serverC", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortC, (int) myconfig, 0,0,0,0,0,0,0,0);
      if (nbEnet > 3)
         rc = taskSpawn("serverD", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortD, (int) myconfig, 0,0,0,0,0,0,0,0);
      if (nbEnet > 4)
         rc = taskSpawn("serverE", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortE, (int) myconfig, 0,0,0,0,0,0,0,0);
      if (nbEnet > 5)
         rc = taskSpawn("serverF", PTYS, OPT, STACK, (FUNCPTR) tcpServer, PortF, (int) myconfig, 0,0,0,0,0,0,0,0);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

As you can see, it is really different from the fork() routine. The point taskSpawn() is like we would ask a different programm to call the function tcpServer() with a context of execution separated.
So is there a routine or a way that allows that with Linux ?

tks a lot : jérémie

** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-embedded mailing list