Sean Boudreau(deleted)
05/12/2010 11:52 AM
post54360
|
On Wed, May 12, 2010 at 05:10:09AM -0400, Lasse Skov wrote:
> Hey
>
> Currently i working on a real-time protocol, and in this code I use mutex to secure shared variables.
>
> I use the tracelogger to see how much time my code takes.
> But sometimes the exact same code takes longer time.
> In a situation it could take 38[uS] and the frame processing after with same data take 40[uS].
> The code is running with high priority 100 and no other task have higher priority.
>
> To find out why it sometimes take longer time I started to investigate my os call.
> And one of them is pthread_mutex_lock and pthread_mutex_unlock.
>
> So I created a small project to see how much time it took to lock and unlock a mutex.
> And I found out that i took 0,23 [uS] to take and free it again.
>
> But sometimes it takes 0,221[uS] and sometimes 0,234[uS].
> Is it normally there is so much "jitter" on this?
>
> Off course the OS should use some time, and it will also depend on what it working on when I ask for a mutex.
>
Depending on how you're measuring the difference may be the kernel
call if there's contention. The fast path is a cmp / exchange
instruction. If that indicates there's contention the kernel
call is made.
Regards,
-seanb
|
|
|