taskLock question - VxWorks

This is a discussion on taskLock question - VxWorks ; From the docs i've learn that a call to taskLock blocks all other task. But when it then blocks itself by e.g. pending on a semaphore it is implicitly unlocked which seems logical because otherwise i would end up in ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: taskLock question

  1. taskLock question

    From the docs i've learn that a call to taskLock blocks all other
    task. But when it then blocks itself by e.g. pending on a semaphore it
    is implicitly unlocked which seems logical because otherwise i would
    end up in a dead lock freezing the entire system. Now my question is
    what happens after the wait condition was fulfilled? Is it
    automatically relocked or is is not and what happens with the internal
    lock count? Any help appreciated.

    TIA,
    Hans


  2. Re: taskLock question


    Hans-J. Ude wrote:
    > From the docs i've learn that a call to taskLock blocks all other
    > task. But when it then blocks itself by e.g. pending on a semaphore it
    > is implicitly unlocked which seems logical because otherwise i would
    > end up in a dead lock freezing the entire system. Now my question is
    > what happens after the wait condition was fulfilled? Is it
    > automatically relocked or is is not and what happens with the internal
    > lock count? Any help appreciated.
    >
    > TIA,
    > Hans


    Hi,

    taskLock() is used to disable the scheduler. but the task will give up
    the control when it is pending for something(e.g a semaphore). but the
    lock will be still there. once the task returns from the wait condition
    lock will be reenabled. execute the program given below

    #include
    #include
    #include


    int task1_id,a;
    int task2_id;
    int task3_id;

    void task1(void);
    void task2(void);
    void task3(void);


    void task1(void)
    {

    int a;
    printf("this is Task1");
    taskLock();
    task2_id = taskSpawn("task2",104
    ,VX_NO_STACK_FILL,100,(FUNCPTR)task2, 0,0,0,0,0,0,0,0,0,0);
    taskShow(task2_id,0);
    printf("Enter a value : ");
    scanf("%d",&a);
    task3_id = taskSpawn("task3",102,VX_NO_STACK_FILL,100,(FUNCPTR)task3
    ,0,0,0,0,0,0,0,0,0,0);
    printf("The entered no is %d",a);
    taskUnlock();

    }

    void task2(void)
    {

    printf("\nThis is Task2");
    taskShow(taskNameToId("task2"),2);

    }

    void task3(void)
    {
    printf("\n This is Task3\n");

    taskShow(taskNameToId("task3"),2);

    }

    void main(void)
    {
    task1_id = taskSpawn("task1", 105, VX_NO_STACK_FILL, 100,
    (FUNCPTR)task1 ,0,0,0,0,0,0,0,0,0,0);
    }


  3. Re: taskLock question

    cool98bb@gmail.com schrieb:

    >Hans-J. Ude wrote:
    >> From the docs i've learn that a call to taskLock blocks all other
    >> task. But when it then blocks itself by e.g. pending on a semaphore it
    >> is implicitly unlocked which seems logical because otherwise i would
    >> end up in a dead lock freezing the entire system. Now my question is
    >> what happens after the wait condition was fulfilled? Is it
    >> automatically relocked or is is not and what happens with the internal
    >> lock count? Any help appreciated.
    >>
    >> TIA,
    >> Hans

    >
    >Hi,
    >
    >taskLock() is used to disable the scheduler. but the task will give up
    >the control when it is pending for something(e.g a semaphore). but the
    >lock will be still there. once the task returns from the wait condition
    >lock will be reenabled. execute the program given below


    Thanks for the info and the example too. It was essential for me.

    regards,
    Hans


+ Reply to Thread