RE: can linux RT thread corrupt global variable?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Well I am not sure than.
Could it be some logic problem in you program ? Just guessing.

On Tuesday, May 06, 2003 1:49 PM, Ming Lei [SMTP:lei.ming@xxxxxxxxx] wrote:
> I used locking for all the reads and writes to cpl when the problem
initialy
> surfaced. Interestingly the problem was the same after locking was used.
> Like I said, the problem either occured during context switch, or during
the
> normal execution of a single thread.
> 
> ----- Original Message -----
> From: "Rokicki, Andrew" <ARokicki@xxxxxxxxxxxxx>
> To: <redhat-devel-list@xxxxxxxxxx>
> Cc: "'Ming Lei'" <lei.ming@xxxxxxxxx>
> Sent: Tuesday, May 06, 2003 5:31 AM
> Subject: RE: can linux RT thread corrupt global variable?
> 
> 
> > I am not an expert on this.
> > As a test try using a mutex to protect cpl from thread switching during
> > modification.
> >
> > //somewhere on top of your program.
> > static pthread_mutex_t mtxThread = PTHREAD_MUTEX_INITIALIZER;
> > ....
> > ...
> > //in you threads.
> > pthread_mutex_lock(&mtxThread);
> > cpl=1234 //however you are modifying it.
> > pthread_mutex_unlock(&mtxThread);
> > ......
> >
> >
> > On Monday, May 05, 2003 8:40 PM, Ming Lei [SMTP:lei.ming@xxxxxxxxx]
wrote:
> > > Platform:
> > > Intel Pentium II; RedHat 7.2 with kernel version 2.4.7-10, libc
2.2.4-13
> > and
> > > gcc 2.96.
> > >
> > > Problem description:
> > >
> > > a program has a thread of priority 12, a thread of priority 10, a
thread
> > of
> > > priority 6, and the main process at priority 0. All the threads except
> > main
> > > process is created with pthread_create, and defined SCHED_FIFO as real
> > time
> > > scheduler policy.
> > >
> > > There is a global variable I define as 'int cpl'. All the threads and
> main
> > > process may alter cpl at any time. cpl may have one of these values
{0,
> > > 0xf000006e, 0xf0000068, 0xe0000000, 0xe0000060}.
> > >
> > > <Problem=> at some point of execution which cpl should be a value say
> > > e0000060, but the actual value retained at cpl is another say
e0000000;
> > that
> > > is, the value is changed without the program actually done anything on
> it.
> > > The retained value I observed is kind of historic value(one of these
> value
> > > in the above set), not the arbituary value. The problem had occured
just
> > > after context switch, also occured during a thread execution.
> > >
> > > <Confirm> I used Intel debug register to track any writing to the cpl
> > memory
> > > address globally, which is the way GDB use for x86 hardware watchpoint
> > > implementation. I could see all the writing from my program to change
> cpl,
> > > but failed to see the source from which the problem occured. So I dont
> > know
> > > what cause the problem.
> > >
> > > Can anyone listening give me a direction or hint on this annoying
> > situation?
> > > Any help is thanked here.
> > >
> > > PS. please cc to this email address.
> > > -Ming
> > >
> > >
> > > Related questions:
> > >
> > > Is linux kernel 2.4.10 considered strictly preemptive such as VxWorks
or
> > > other RTOS? I guess 2.4.10 may simulate preemptive with running
> scheduler
> > on
> > > every syscall or interrupt returns. Am I right?
> > >
> > > Is printf() real-time priority thread safe?
> > >
> > >
> > >
> > > _______________________________________________
> > > Redhat-devel-list mailing list
> > > Redhat-devel-list@xxxxxxxxxx
> > > https://listman.redhat.com/mailman/listinfo/redhat-devel-list



_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux