Jan Kiszka wrote:
Hi Paolo,

you once ask me to test your corrected rt_task_delete in the cvs. I did not make it yet to that point, I was stopped by a more critical problem showing up in the cvs but not in 3.1:

task_fun()
{
    while (1) {
        if (rt_sem_wait(&sem) == SEM_ERR)
            return;

        /* do some stuff */
    }
}

init()
{
    rt_typed_sem_init(&sem, 0, CNT_SEM);
    rt_task_init(&task, task_fun, ...);
}

cleanup()
{
    rt_sem_delete(&sem);
    rt_task_delete(&task);
}

Gives some nice kernel crash, flodding my console without a chance to see the first error.

Do you see an obvious reason for this? Or should I dig deeper? I think something is terminated twice (1. by leaving task_fun, 2. by rt_task_delete) without catching this special case.

Jan


PS: I know it is not a nice way to shut down (with respect to SMP), but it is safe in our case because task_fun is known to block on the semaphore on deletion.


It does not show up in 3.1 because the supporting hrdened real time kthread just suspends while in the CVS exits also.
The following might be a solution (SMP safe also):

static RT_TASK task;
static SEM sem;

void task_fun(int a)
{
    while (1) {
        if (rt_sem_wait(&sem) == SEM_ERR) {
                return;
        }
    }
}

int init_module(void)
{
    rt_typed_sem_init(&sem, 0, CNT_SEM);
    rt_task_init(&task, task_fun, 0, 2000, 0, 0, 0);
    rt_task_resume(&task);
    return 0;
}

void cleanup_module(void)
{
    rt_sem_delete(&sem);
    rt_printk("SEM DELETED\n");
    set_cpus_allowed(current, cpumask_of_cpu(task.runnable_on_cpus));
    if (task.magic) {
        rt_task_delete(&task);
        rt_printk("TASK DELETED\n");
    }
}

More care will be exercised when LXRT will really be the _only_ scheduler.

Paolo.



Reply via email to