Hmm.. just playing around with pointers should not take that long
(unless you are like on a 16 MHz 386sx or something).

Here's one possible explanation that doesn't really account for the 5ms
run-time of each thread, but does account for the observed phenomenon that
1 thread running 1 task will display significantly lower run times than 2
threads that share a mutex running the same task:

1) Thread A acquires lock
2) Thread B wants lock, but can't get it so sleeps
3) Thread A does work that takes time T
4) Thread A releases lock
5) Thread B is immediately awoken because it was next-in-line for the
mutex
6) Thread B does work that takes roughly time T as well
7) Thread B releases lock
8) goto (1)

As you can see, thread B did work that took time T, but ended up taking
over 2T's work of time to do it.

Now this is a sort of obvious example.. but could it be enough to explain
your really long run times?  Maybe if you posted some code I might be able
to help better?  Thanks...


-Calin

following:  On Sat, 29 Sep 2001, lionel wrote:

> The process portion is extremely short : removing the head element of a
> queue then putting it at the tail of the queue, this is done 10 times. This
> does not make sense, but this is done just for test purpose.
> ----- Original Message -----
> From: "Calin A. Culianu" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, September 27, 2001 5:40 PM
> Subject: Re: [rtl] SMP mutex/scheduling problem ?
>
>
> >
> > That's weird... How long does the process portion alone take?
> >
> > On Tue, 25 Sep 2001, lionel wrote:
> >
> > > The context :
> > > We are designing a realtime Radio Link Control driver with hard real
> time
> > > constraints.
> > >
> > >
> > > We launch 2 threads on a bi processor, 1 thread on P1, 1 thread on P2.
> > > Both threads run in an infinite loop and both are periodic (10 milli
> > > seconds).
> > > Both treads try to lock a mutex, make a few code then unlock the mutex
> (they
> > > try to access a shared list protected by a mutex).
> > > The execution time of the code between the lock and the unlock of the
> mutex
> > > is no more than a few micro seconds.
> > >
> > > But when I mesure the execution time of the code that lock, process, and
> > > then unlock the mutex with the help of the function clock_gethrtime(), I
> can
> > > notice than sometimes it take 5 milli seconds (the value is nearly
> always
> > > the same : 5ms +/- a few micro seconds) ???.
> > >
> > > Any help would be appreciated.
> > >
> > > Thanks.
> > >
> > > -----------------------------------------------------
> > > Hardware : Bi processor PIII 1 GHz 512Mo
> > > -----------------------------------------------------
> > > Software :
> > >   Redhat 7.1
> > >   Kernel 2.4.4 from kernel.org
> > >   RT-Linux 3.1
> > > -----------------------------------------------------
> > > Code for thread 1 (idem for thread 2 except counter2):
> > >
> > > void *thread_test1(void* notusedP) {
> > >
> > >   hrtime_t start, end, process;
> > >   pthread_make_periodic_np(pthread_self(), gethrtime(),   10000000); /*
> 10
> > > milli seconds */
> > >
> > >   while (1) {
> > >
> > >     start = gethrtime();
> > >
> > >    /* code that acquire a mutex here not detailled */
> > >
> > >     end = gethrtime();
> > >     process = end - start;
> > >     if (process > 1000000) { /* 1 milli second */
> > >       counter1+=1; // extern variable displayed when cleaning up the
> module
> > >     }
> > >     pthread_wait_np();
> > >   }
> > > }
> > >
> > >
> > > -- [rtl] ---
> > > To unsubscribe:
> > > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> > > --
> > > For more information on Real-Time Linux see:
> > > http://www.rtlinux.org/
> > >
> >
> > -- [rtl] ---
> > To unsubscribe:
> > echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> > echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> > --
> > For more information on Real-Time Linux see:
> > http://www.rtlinux.org/
> >
> >
>
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
>

-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to