Re: Task Pending on Semaphore



On Oct 24, 8:15 pm, Daniel <dantheman0...@xxxxxxxxx> wrote:
I have an interesting problem. I have a task A at priority 170. My
code has a bunch of other tasks at several other priorities, both
above and below 170. There are a few tasks running at priority 120.
Occasionally task A will increase its priority to 170. This looks
like to be a task priority inversion problem. How do I determine what
semaphore its pending on and who else owns it?

Thanks in advance,
-Daniel

How this is done will depend upon the version of VxWorks you are
using. I don't think that there is a show command that will do this
for you. So, to do this yourself, you will need to inspect the task
control block (TCB). I am assuming that you are either using VxWorks
5.x or running in the kernel for 6.x. This is easy to get in the
aforementionned cases. Your taskId returned by taskSpawn(),
taskCreate(), or even taskIdSelf() is a pointer to the WIND_TCB ...
the Wind River task control block. Reference the file target/h/
taskLib.h for the exact field names that I am referring to next.

There is a field called something like pPendQ. If this is not NULL,
this identifies the queue that the task is pended upon. If memory
serves, this pend queue typically belongs to either a semaphore or a
message queue. The pend queues are at fixed offsets within a
semaphore structure and message queue structure. So, you can take
your pPendQ pointer, subtract the offset and test the resulting
pointer against the semaphore type and message queue type. If either
one passes, you have your object. In VxWorks (non-RTP cases) the
object ID is really a pointer to the object.

Now, if the object is pended upon an inversion safe mutex semaphore,
the semaphore ID (or pointer to the semaphore) is saved in the TCB's
pPriMutex field. In 6.x versions, if I remember correctly, this field
is embedded in the priority inheritance data structure (which was
added when the priority inheritance algorithm was improved). So, in
that case, if you want to determine what task "owns" the mutex on
which a task is blocking it is ...
pBlockedTcb->pPriMutex->semOwner for 5.x
pBlockedTcb->pPriData->pPriMutex->semOwner for 6.x

Hope this helps.

Peter

.



Relevant Pages

  • Re: Task Pending on Semaphore
    ... Occasionally task A will increase its priority to 170. ... semaphore its pending on and who else owns it? ... or even taskIdSelfis a pointer to the WIND_TCB ... ... semaphore structure and message queue structure. ...
    (comp.os.vxworks)
  • Re: output.c error in multithreaded program
    ... >please see further below about a couple of semaphore questions). ... just modify your queue insertion routine to put the request in the ... scheduling priorities give you control over priority of how things are done). ... Why have an array of handles and an array of counts when the natural ...
    (microsoft.public.vc.mfc)
  • Re: output.c error in multithreaded program
    ... AfxBeginThread. ... please see further below about a couple of semaphore questions). ... previously waiting thread with a lower priority. ... GetHttpFile and all the other internet stuff is basically a cut and paste ...
    (microsoft.public.vc.mfc)
  • Re: How to read IO-APIC registers?
    ... I'm trying to read settings IO-APIC and LAPIC (read registers). ... I can't read reserved memory area by pointer like this. ... I will try to change priority ... kernel will not let regular user programs access hardware directly. ...
    (comp.programming)
  • Re: [patch] Real-Time Preemption, -RT-2.6.11-rc2-V0.7.37-02
    ... > zeroing the semaphore, the machine hangs. ... The parent process that zeros the semaphore to allow the child process ... I also found that the high priority child is running in an infinite ...
    (Linux-Kernel)