Question about signal handler execution - VxWorks

This is a discussion on Question about signal handler execution - VxWorks ; Hi all, Just remember a question about the signal handler. Assume we have a program like this: sig_hdr () {} task_low_priority() { ... signal(SIGUSR1, sig_hdr); ... } task_high_priority() { ... kill(pid, SIGUSR1); //pid is the ID of task_low_priority ... } ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Question about signal handler execution

  1. Question about signal handler execution

    Hi all,

    Just remember a question about the signal handler. Assume we have a
    program like this:

    sig_hdr () {}

    task_low_priority() {
    ...
    signal(SIGUSR1, sig_hdr);
    ...
    }

    task_high_priority() {
    ...
    kill(pid, SIGUSR1); //pid is the ID of task_low_priority
    ...
    }

    If task_high_priority is running and kill SIGUSR1, will the
    task_low_priority get executed immediately? In another word, task with
    high priority can be preempted by a lower priority task when raising a
    signal like this?

    Thanks!!


  2. Re: Question about signal handler execution

    On May 1, 9:32 pm, david wrote:
    > Hi all,
    >
    > Just remember a question about the signal handler. Assume we have a
    > program like this:
    >
    > sig_hdr () {}
    >
    > task_low_priority() {
    > ...
    > signal(SIGUSR1, sig_hdr);
    > ...
    >
    > }
    >
    > task_high_priority() {
    > ...
    > kill(pid, SIGUSR1); //pid is the ID of task_low_priority
    > ...
    >
    > }
    >
    > If task_high_priority is running and kill SIGUSR1, will the
    > task_low_priority get executed immediately? In another word, task with
    > high priority can be preempted by a lower priority task when raising a
    > signal like this?
    >


    Preempted isn't really what you mean here.
    You're asking (I think) whether or not calling kill() will cause a
    high priority task to block while a low priority task handles the
    signal.
    I doubt it, although the sigLib docs don't spell it out.
    The signal handler is executed in the context of the task that
    'catches' the signal.
    I have to believe the low priority task won't actually handle the
    signal until it becomes the highest priority ready task.
    The low priority task may be blocked waiting for some other event that
    is never going to happen, it would simply be made ready when kill() is
    called.
    It would be easy enough to write a little test application to
    determine the actual behavior.
    Windview (or System Viewer) would make it all perfectly clear on a
    graph.

    HTH,
    GV


+ Reply to Thread