Thank you for your explanation about thread !
 
Always in the same bug, I'll try to test my configuration with this program.
RR timeslice =10ms ticks=1/ms
and  two task (with same priority) that increase a counter variable each time that it takes again the cpu.
We can See the result see bellow:
 
    Xenomai/uvm: real-time nucleus v2.1 (Champagne) loaded.
    starting VxWorks services.
    Start 0 taskChanged 0
    Start testRun1 0 taskChanged 0
    Run testRun1 0 taskChanged 1
    Start testRun2 10 taskChanged 1
    Run testRun2 10 taskChanged 2
    Run testRun1 20 taskChanged 3
    Run testRun2 30 taskChanged 4
    Run testRun1 40 taskChanged 5
    Run testRun2 50 taskChanged 6
    End testRun1 60 taskChanged 6
    End testRun2 60 taskChanged 6
    End 150 taskChanged 6
 
The period is put to 500ms (taskPeriod =50), and we can see than every 10ms the context change. OK
But now my problem is: If I change the number of my period "taskPeriod". My computer freezes  without any print.
So, It's this problem than I don't understand. Can anybody help me? 
 
#include "vxworks/vxworks.h"
#define CLK_RATE 50
#define SSEXEC_SYSCLKRATE 1000
#define SSEXEC_TIMESLICE 10
 
static SEM_ID _semaphoreId;
static int taskRunning = 0;
static int taskChanged = 0;
#define taskPeriod 50               // <<<<<<<<<<<<<<<<<
 
void testRun1()
{
    printf("Start testRun1 %d taskChanged %d\n", (int)tickGet(), taskChanged);
    const unsigned int taskId = 1;
    unsigned int startTime1 = tickGet();
 
    while(tickGet() < (startTime1 + taskPeriod))
    {
        if(semTake(_semaphoreId, WAIT_FOREVER) != OK) return;
        if(taskRunning != taskId)
        {
            taskRunning = taskId;
            taskChanged++;
            printf("Run testRun1 %d taskChanged %d\n", (int)tickGet(), taskChanged);
        }
        if(semGive(_semaphoreId) != OK) return;
    }
    printf("End testRun1 %d taskChanged %d\n", (int)tickGet(), taskChanged);
}
 
void testRun2()
{
    printf("Start testRun2 %d taskChanged %d\n", (int)tickGet(), taskChanged);
    const unsigned int taskId = 2;
    unsigned int startTime1 = tickGet();
 
    while(tickGet() < (startTime1 + taskPeriod))
    {
        if(semTake(_semaphoreId, WAIT_FOREVER) != OK) return;
        if(taskRunning != taskId)
        {
            taskRunning = taskId;
            taskChanged++;
            printf("Run testRun2 %d taskChanged %d\n", (int)tickGet(), taskChanged);
        }
        if(semGive(_semaphoreId) != OK) return;
    }
    printf("End testRun2 %d taskChanged %d\n", (int)tickGet(), taskChanged);
}
 
int CreateTask(void)
{
    _semaphoreId = semMCreate(SEM_Q_PRIORITY);
    printf("Start %d taskChanged %d\n", (int)tickGet(), taskChanged);
 
    int taskRun1 = taskSpawn("testRun1",100, VX_FP_TASK, 0x5000,(FUNCPTR)testRun1, 0,1,2,3,4,5,6,7,8,9 );
    int taskRun2 = taskSpawn("testRun2",100, VX_FP_TASK, 0x5000,(FUNCPTR)testRun2, 0,1,2,3,4,5,6,7,8,9 );
    taskDelay(taskPeriod + 100);
 
    printf("End %d taskChanged %d\n", (int)tickGet(), taskChanged);
    return OK;
}
 
int rootTask (void)
{
    sysClkRateSet(SSEXEC_SYSCLKRATE);
    tickSet(0);
    kernelTimeSlice(SSEXEC_TIMESLICE);
    CreateTask();
    return OK;
}
 
int root_thread_init (void)
{
    return !taskSpawn("root",0,VX_FP_TASK,0x5000,(FUNCPTR)rootTask, 0,0,0,0,0,0,0,0,0,0 );
}
 
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Reply via email to