problem with shared data structure - VxWorks
This is a discussion on problem with shared data structure - VxWorks ; Hi,
I have two tasks, say T1 and T2. T1 is of lower priority than T2.
And a data structure, say D, shared by both the tasks. T1 task writes
D and T2 reads D. T2 must read D, after ...
-
problem with shared data structure
Hi,
I have two tasks, say T1 and T2. T1 is of lower priority than T2.
And a data structure, say D, shared by both the tasks. T1 task writes
D and T2 reads D. T2 must read D, after T1 writes D. But sometimes,
the task T2 is reading D before T1 writes D. There are more than one
task of type T1(writing tasks), say some 20. I want to make T2,
everytime, to read D only after T1 writes into D. Could you please let
me know how to do this in vxworks?
Warm Regards
-
Re: problem with shared data structure
ramu escribió:
> Hi,
> I have two tasks, say T1 and T2. T1 is of lower priority than T2.
> And a data structure, say D, shared by both the tasks. T1 task writes
> D and T2 reads D. T2 must read D, after T1 writes D. But sometimes,
> the task T2 is reading D before T1 writes D. There are more than one
> task of type T1(writing tasks), say some 20. I want to make T2,
> everytime, to read D only after T1 writes into D. Could you please let
> me know how to do this in vxworks?
Semaphore.
-
Re: problem with shared data structure
On Jul 22, 6:53*pm, "Ignacio G.T."
wrote:
> ramu escribió:
>
> > Hi,
> > * * *I have two tasks, say T1 and T2. T1 is of lower priority than T2.
> > And a data structure, say D, shared by both the tasks. T1 task writes
> > D and T2 reads D. T2 must read D, after T1 writes D. But sometimes,
> > the task T2 is reading D before T1 writes D. There are more than one
> > task of type T1(writing tasks), say some 20. I want to make T2,
> > everytime, to read D only after T1 writes into D. Could you please let
> > me know how to do this in vxworks?
>
> Semaphore.
Yes,
Semaphores is the best solution I feel.
First create a binary semaphore with SEM_EMPTY option.
And the tasks which are writing the data into the shared area should
release
the semaphore once they have written the data.
The task that is reading from the share data should acquire the
semaphore
before reading from the shared data area.
Let me know wheather this works or not.
Nagarjuna