Hello
I have Problems spawning a Task from a Task under the vxworks skin!
If I spawn my Tasks from a Funktion - it works!
If I spawn my Tasks from a Task - system crashes!
Here the programm:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/io.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <vxworks/vxworks.h>
#include "vxChain.h"
#include "portutils.h"
#define PRIORITY_LOW 100
#define PRIORITY_MID 90
#define PRIORITY_HIGH 80
#define USE_FPU (VX_FP_TASK | VX_NO_STACK_FILL)
#define NO_FPU VX_NO_STACK_FILL
#define STACK_SIZE 0x5000
#define TASK_OPTIONS USE_FPU
#define NUM_TASKS 8
#define MAX_TASKS 15
SEM_ID semId[MAX_TASKS * 2];
int taskId[MAX_TASKS];
int triggerId;
int root_thread_init()
{
// Allow port I/O in userspace
iopl(3);
vxTest(); // Just a function call (works)
// vxSpawn(); // Spawns the function as a task (crashes)
return 0;
}
void vxSpawn( void )
{
taskSpawn ("Master Task", PRIORITY_HIGH,
TASK_OPTIONS, STACK_SIZE,
(FUNCPTR) vxTest,
0,0,0,0,0,0,0,0,0,0);
}
void root_thread_exit (void)
{
printf ("root_thread_exit() called.\n");
}
void vxTest( void )
{
int i;
char buf[80];
for (i=0; i < NUM_TASKS; i++)
{
semId[2*i] = semBCreate( SEM_Q_PRIORITY, SEM_EMPTY);
semId[2*i+1] = semBCreate( SEM_Q_PRIORITY, SEM_EMPTY);
}
for (i=0; i < NUM_TASKS; i++)
{
sprintf(buf, "Task_%d", i);
taskId[i] =
taskSpawn(buf, PRIORITY_LOW, TASK_OPTIONS, STACK_SIZE,
(FUNCPTR) WorkerTask,
i, // Task Nummer
semId[i], // warten auf Semaphor
semId[i+1], // anzutriggerndes Semaphor
0,0,0,0,0,0,0);
printf ("task[%d] = 0x%08X, errno = %d\n", i, taskId[i],
errnoGet());
}
triggerId = taskSpawn ("Trigger task", PRIORITY_MID,
TASK_OPTIONS, STACK_SIZE,
(FUNCPTR) TriggerTask,
0,0,0,0,0,0,0,0,0,0);
printf ("taskTrigger = 0x%08X\n", triggerId);
taskSuspend(taskIdSelf());
}
void TriggerTask( void )
{
while( 1 )
{
taskDelay(1);
semGive(semId[0]);
}
}
FUNCPTR WorkerTask(int i0,int i1,int i2,int i3,int i4,int i5,int i6,int
i7,int i8,int i9)
{
unsigned int task_num = (unsigned int) i0;
int sem_to_wait = i1;
int sem_to_trigger = i2;
iopl(3);
while (1)
{
semTake(sem_to_wait, WAIT_FOREVER);
if (task_num < 8)
{
lpt_peak_bit (task_num);
}
semGive(sem_to_trigger);
}
return 0;
}
Fusion 0.9.1
Kernel 2.6.13-ipipe
Suse 9.3
Any Ideas?
Thanks
Jan-Peter
--
Lust, ein paar Euro nebenbei zu verdienen? Ohne Kosten, ohne Risiko!
Satte Provisionen für GMX Partner: http://www.gmx.net/de/go/partner